Updating applications
Now we can use Argo CD and Kustomize to deploy patches to our application manifests using GitOps. For example, lets increase the number of replicas
for ui
deployment to 3
.
You can execute commands to add necessary changes to the file apps-kustomization/ui/deployment-patch.yaml
:
~$yq -i '.spec.replicas = 3' ~/environment/argocd/apps-kustomization/ui/deployment-patch.yaml
You can review planned changes in the file apps-kustomization/ui/deployment-patch.yaml
.
- Kustomize Patch
- Deployment/ui
- Diff
~/environment/eks-workshop/modules/automation/gitops/argocd/update-application/deployment-patch.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: ui
spec:
replicas: 3
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/created-by: eks-workshop
app.kubernetes.io/type: app
name: ui
namespace: ui
spec:
replicas: 3
selector:
matchLabels:
app.kubernetes.io/component: service
app.kubernetes.io/instance: ui
app.kubernetes.io/name: ui
template:
metadata:
annotations:
prometheus.io/path: /actuator/prometheus
prometheus.io/port: "8080"
prometheus.io/scrape: "true"
labels:
app.kubernetes.io/component: service
app.kubernetes.io/created-by: eks-workshop
app.kubernetes.io/instance: ui
app.kubernetes.io/name: ui
spec:
containers:
- env:
- name: JAVA_OPTS
value: -XX:MaxRAMPercentage=75.0 -Djava.security.egd=file:/dev/urandom
envFrom:
- configMapRef:
name: ui
image: public.ecr.aws/aws-containers/retail-store-sample-ui:0.4.0
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 45
periodSeconds: 20
name: ui
ports:
- containerPort: 8080
name: http
protocol: TCP
resources:
limits:
memory: 1.5Gi
requests:
cpu: 250m
memory: 1.5Gi
securityContext:
capabilities:
add:
- NET_BIND_SERVICE
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
volumeMounts:
- mountPath: /tmp
name: tmp-volume
securityContext:
fsGroup: 1000
serviceAccountName: ui
volumes:
- emptyDir:
medium: Memory
name: tmp-volume
app.kubernetes.io/type: app
name: ui
namespace: ui
spec:
- replicas: 1
+ replicas: 3
selector:
matchLabels:
app.kubernetes.io/component: service
app.kubernetes.io/instance: ui
Push changes to the Git repository:
~$git -C ~/environment/argocd add .
~$git -C ~/environment/argocd commit -am "Update UI service replicas"
~$git -C ~/environment/argocd push
Click Refresh
and Sync
in ArgoCD UI, use argocd
CLI to Sync
the application or wait until automatic Sync
will be finished:
~$argocd app sync ui
To verify, run the following commands:
~$kubectl get deployment -n ui ui
NAME READY UP-TO-DATE AVAILABLE AGE
ui 3/3 3 3 3m33s
~$kubectl get pod -n ui
NAME READY STATUS RESTARTS AGE
ui-6d5bb7b95-hzmgp 1/1 Running 0 61s
ui-6d5bb7b95-j28ww 1/1 Running 0 61s
ui-6d5bb7b95-rjfxd 1/1 Running 0 3m34s