Skip to content

Commit 4a6e7ce

Browse files
authored
fixed some of the text in the latest post (#25)
Signed-off-by: David Söderlund <[email protected]>
1 parent a858d94 commit 4a6e7ce

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

docs/_posts/2024-06-06-cdks8s-through-argocd.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ published: true
77
- [ArgoCD in short](#argocd-in-short)
88
- [cdk8s in short](#cdk8s-in-short)
99
- [An example](#an-example)
10-
- [Adding a cdk8s plugin to argocd](#adding-a-cdk8s-plugin-to-argocd)
10+
- [Adding a cdk8s plugin to ArgoCD](#adding-a-cdk8s-plugin-to-argocd)
1111
- [Dockerfile](#dockerfile)
1212
- [Plugging in as an argo-repo-server sidecar](#plugging-in-as-an-argo-repo-server-sidecar)
13+
- [Results when using the plugin](#results-when-using-the-plugin)
1314
- [ArgoCD documentation and further reading](#argocd-documentation-and-further-reading)
1415
- [The point of all this](#the-point-of-all-this)
1516

@@ -20,9 +21,7 @@ cdk8s is a tool from AWS to be able to deal with kubernetes manifests in an impe
2021

2122
## ArgoCD in short
2223

23-
Chances are if you are reading this you already know a bit about ArgoCD. It allows us to package kubernetes manifests in "applications" which helps to compartmentalize things that you are managing inside kubernetes as well as giving a cli and a UI in that abstraction level. For each application we can choose how we want to observe and synchronize the declared state of our application as ArgoCD he from git into kubernetes.
24-
25-
https://argo-cd.readthedocs.io/en/stable/
24+
Chances are if you are reading this you already know a bit about [ArgoCD](https://argo-cd.readthedocs.io/en/stable/). It allows us to package kubernetes manifests in "applications" which helps to compartmentalize things that you are managing inside kubernetes as well as giving a cli and a UI in that abstraction level. For each application we can choose how we want ArgoCD to observe and synchronize the declared state of our application from git to kubernetes.
2625

2726
## cdk8s in short
2827

@@ -146,15 +145,15 @@ spec:
146145

147146
```
148147

149-
## Adding a cdk8s plugin to argocd
148+
## Adding a cdk8s plugin to ArgoCD
150149

151-
While learning about cdk8s I was surprised to learn that it didn't work out of the box with argocd, and that I couldn't find any pre-made plugins.
150+
While learning about cdk8s I was surprised to learn that it didn't work out of the box with ArgoCD, and that I couldn't find any pre-made plugins.
152151

153-
I did however come across [this great post about cdk8s by Max Brenner](https://shipit.dev/posts/integrating-cdk8s-with-argocd.html) and also [their repository on how to run cdk8s in a container](https://github.com/brennerm/cdk8s-docker).
152+
I did however come across [this great post about cdk8s by Max Brenner](https://shipit.dev/posts/integrating-cdk8s-with-ArgoCD.html) and also [their repository on how to run cdk8s in a container](https://github.com/brennerm/cdk8s-docker).
154153

155154
### Dockerfile
156155

157-
From there I built my own version of the typescript container such that it would work without running as root which argocd plugins are not allowed to do for good reason.
156+
From there I built my own version of the typescript container such that it would work without running as root which ArgoCD plugins are not allowed to do for good reason.
158157

159158
``` Dockerfile
160159
# docker.io/dsoderlund/cdk8s:typescript
@@ -176,14 +175,22 @@ The entrypoint.sh script allows you to run this from the command line and get it
176175

177176
### Plugging in as an argo-repo-server sidecar
178177

179-
So the idea here is that we want argocd repository server to render the yaml for us by invoking `cdk8s synth` for an app just like it does for helm, kustomize, or plain yaml. It should do this if it knows that it is a cdk8s-typescript style apps which is evident by the presence of the file `./imports/k8s.ts`.
178+
So the idea here is that we want ArgoCD repository server to render the yaml for us by invoking `cdk8s synth` for an app just like it does for helm, kustomize, or plain yaml. ArgoCD should do this if it can tell that it is seeing a cdk8s-typescript style application. This will be evident by the presence of the file `./imports/k8s.ts`.
180179

181-
There is a working example you can clone and run in [my reference platform github repo](https://github.com/QuadmanSWE/ds-ref-platform/blob/main/2_platform/argocd/kustomization.yaml). Here is what the running app looks like through argocd.
180+
The execution has three parts, init, command, and discover.
182181

183-
![](../assets/2024-06-06-15-03-01.png)
182+
- Init will run before anything else to make preparations. `npm install` will make sure the container has everything needed to perform the `cdk8s synth` step. This will be cached in the container and kept for future ArgoCD synchs of the app.
183+
184+
- Command executes the synth, ignores any direct output, and then reads the resulting file(s) from the dist folder.
185+
186+
- Discover helps repo-server know that this is infact a cdk8s-typescript style application and that this plugin applies.
187+
188+
There is a working example you can clone and run in [my reference platform github repo](https://github.com/QuadmanSWE/ds-ref-platform/blob/main/2_platform/argocd/kustomization.yaml).
189+
190+
This is an excerpt of that working example that highlights the parts that configures and injects the plugin.
184191

185192
``` yaml
186-
# ... Removed for brevity, imagine an argocd helm values declaration.
193+
# ... Removed for brevity, imagine an ArgoCD helm values declaration.
187194
configs:
188195
cmp:
189196
create: true
@@ -230,6 +237,13 @@ repoServer:
230237
emptyDir: {}
231238
```
232239
240+
### Results when using the plugin
241+
242+
Here is what the running app looks like through ArgoCD.
243+
244+
![](../assets/2024-06-06-15-03-01.png)
245+
246+
233247
### ArgoCD documentation and further reading
234248
235249
[Here is the docs for how these config mangement plugins works.](https://argo-cd.readthedocs.io/en/stable/operator-manual/config-management-plugins/) I also recommend reading [this](https://dev.to/ali_nazari_f9773d74e0b0e4/using-cdk8s-ytt-or-gomplate-with-argocd-through-config-management-plugins-4f6g) and [this](https://codefresh.io/blog/using-argo-cds-new-config-management-plugins-to-build-kustomize-helm-and-more/) article which though using different approaches and a bit different end results than what I am after, do a great job in explaining what all the different parts are.

0 commit comments

Comments
 (0)