Kustomize allows for last-mile patches (i.e. modifications) to the app that are otherwise not configurable via Config
page.
Click on View files
and lets take a look at the directory structure.
The upstream
directory mirrors exactly the content pushed to a release.
This includes the template functions, preflight checks, support-bundle, config options, license etc.
In addition, it has a userdata
directory which includes the license file, config file, etc.
Note: With the exception of upstream/userdata
, no changes should be made in the upstream
directory as they are overwritten on each new release.
After KOTS processes and renders the upstream
, it puts those files in the base
directory.
Any non-deployable manifests such as template functions, preflight checks, config options, etc. are removed, and only the “deployable” application (i.e. deployable with kubectl apply
) will be placed here.
Note: No changes should be made in the base
directory as they are overwritten on each new release.
The overlays
directory references the base
directory and this is where your local kustomize patches should be placed.
Unlike upstream
and base
, any changes made here will persist between releases.
Since upstream
and base
are ephemeral, lets make a kustomize patch in overlays/downstreams/this-cluster/
so it persists between releases.
Go to View Files
and click on Need to edit these files? Click here to learn how
.
To download the KOTS app locally
export APP_NAMESPACE=app-namespace
export APP_SLUG=app-slug
kubectl kots download --namespace ${APP_NAMESPACE} --slug ${APP_SLUG} --dest ~/my-kots-app
• Connecting to cluster ✓
Lets patch something simple like the replicas
count.
Create a file in ~/my-kots-app/overlays/downstreams/this-cluster/patch-deployment.yaml
with the following:
cat <<EOF >>~/my-kots-app/overlays/downstreams/this-cluster/patch-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-nginx
spec:
replicas: 2
EOF
Don’t forget to add this file under patches
in ~/my-kots-app/overlays/downstreams/this-cluster/kustomization.yaml
@@ -2,3 +2,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
bases:
- ../../midstream
kind: Kustomization
+patches:
+- ./patch-deployment.yaml
Upload the KOTS app to the cluster.
export APP_NAMESPACE=app-namespace
export APP_SLUG=app-slug
kubectl kots upload --namespace ${APP_NAMESPACE} --slug ${APP_SLUG} ~/my-kots-app
• Uploading local application to Admin Console ✓
Under View history
you should see a new version ready to deploy along with the diff of the changes we pushed in the last few steps.
Before deploying ensure there is only 1 nginx pod running.
$ kubectl get po | grep example-nginx
example-nginx-f5c49fdf6-bf584 1/1 Running 0 1h
Click Deploy
to apply the changes.
You should now see 2 nginx pods running.
$ kubectl get po | grep example-nginx
example-nginx-f5c49fdf6-bf584 1/1 Running 0 1h
example-nginx-t6ght74jr-58fhr 1/1 Running 0 1m