-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Create and publish a cdk8s-cmp-java Docker image | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'cdk8s-cmp-java/v*' | ||
env: | ||
REGISTRY: ghcr.io | ||
ACTOR: ${{ github.actor }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
env: | ||
IMAGE_NAME: cdk8s-cmp-java | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ env.ACTOR }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.ACTOR }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=match,pattern=v(.*),group=1 | ||
flavor: | | ||
latest=auto | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: ./java | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
ARG NODE_VERSION=20.11.0 | ||
ARG CDK8S_CLI_VERSION=2.198.36 | ||
ARG ALPINE_VERSION=3.15 | ||
|
||
FROM --platform=${BUILDPLATFORM} node:${NODE_VERSION}-alpine as node | ||
|
||
FROM alpine:${ALPINE_VERSION} | ||
|
||
USER root | ||
|
||
RUN addgroup -g 1000 argocd && \ | ||
adduser -S -u 999 -G argocd -h /home/argocd argocd && \ | ||
mkdir -p /home/argocd && \ | ||
chown argocd:0 /home/argocd && \ | ||
chmod g=u /home/argocd | ||
|
||
COPY --from=node /usr/lib /usr/lib | ||
COPY --from=node /usr/local/lib /usr/local/lib | ||
COPY --from=node /usr/local/include /usr/local/include | ||
COPY --from=node /usr/local/bin /usr/local/bin | ||
|
||
RUN apk add --no-cache \ | ||
openjdk11 \ | ||
maven | ||
|
||
RUN npm install -g cdk8s-cli@${CDK8S_CLI_VERSION} | ||
|
||
USER argocd | ||
|
||
WORKDIR /home/argocd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# cdk8s Java CMP | ||
|
||
This generates kubernetes manifests using cdk8s in Java language. [Read more about cdk8s Java](https://cdk8s.io/docs/latest/get-started/java/) | ||
|
||
## Use-case | ||
|
||
When you have kubernetes manifests written in cdk8s Java and you want to turn it into raw YAML and provide ArgoCD to manage resources. | ||
|
||
Basically it requires 2 commands when generating raw YAML manifests | ||
|
||
1. Import cdk8s objects defined in cdk8s configuration YAML file and compile java | ||
|
||
```sh | ||
cdk8s import && mvn compile | ||
``` | ||
|
||
2. Generate manifests and print to stdout | ||
|
||
```sh | ||
cdk8s synth --stdout | ||
``` | ||
|
||
## Install and Use | ||
|
||
Register the plugin sidecar to `argocd-repo-server` | ||
|
||
```yaml | ||
containers: | ||
- name: cdk8s-java | ||
image: ghcr.io/akuity/cdk8s-cmp-java:latest | ||
.... | ||
``` | ||
|
||
Apply [this plugin.yaml](./plugin.yaml) configuration. You can modify depending on your use-case (ie. for example injecting static or dynamic parameters). | ||
|
||
Use the plugin when you create an application. | ||
|
||
```yaml | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: guestbook | ||
spec: | ||
source: | ||
plugin: | ||
name: cdk8s-java | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: ConfigManagementPlugin | ||
metadata: | ||
name: cdk8s-java | ||
spec: | ||
version: v1.0 | ||
init: | ||
command: [sh, -c] | ||
args: [cdk8s import && mvn compile] | ||
generate: | ||
command: [cdk8s, synth] | ||
args: [--stdout] | ||
discover: | ||
fileName: "pom.xml" |