This repository contains Kubernetes manifests that will be delivered to Neco data centers automatically by Argo CD.
Determine the name of the new application, then make base
directory for it:
$ APP_NAME=foo
$ mkdir -p ${APP_NAME}/base
Manifests that are common to all environments go to base
directory.
A manifest can be incomplete as long as it will be complemented by overlays as described later.
Note that manifests extension should be .yaml
instead of .yml
because ArgoCD searches only *.yaml
files.
$ edit ${APP_NAME}/base/deployment.yaml
$ edit ${APP_NAME}/base/service.yaml
Then, create kustomization.yaml
for Kustomize.
$ cat <<EOF > ${APP_NAME}/base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
EOF
For each data center such as gcp
, stage0
, tokyo0
, you may create
patch manifets as follows:
$ ENV=stage0
$ mkdir -p ${APP_NAME}/overlays/${ENV}
$ vi ${APP_NAME}/overlays/${ENV}/deployment_replicas.yaml
Create kustomization.yaml
to apply patches to base manifets.
$ cat <<EOF > ${APP_NAME}/overlays/${ENV}/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
patchesStrategicMerge:
- deployment_replicas.yaml
EOF
$ (cd test; make setup)
$ kustomize build ${APP_NAME}/base > /tmp/app.yaml
$ kustomize build ${APP_NAME}/overlays/${ENV} > /tmp/app_${ENV}.yaml
$ diff -u /tmp/app.yaml /tmp/app_${ENV}.yaml
Apply the generated manifest using kubectl apply --dry-run -f FILE
in the dctest environment.
Add following files under argocd-config
directory:
$ edit argocd-config/base/${APP_NAME}.yaml
$ edit argocd-config/overlays/${ENV}/${APP_NAME}.yaml
Examples are argocd-config/base/metallb.yaml and argocd-config/overlays/stage0/metallb.yaml.
Add the filenames to kustomization.yaml
for ArgoCD.
$ edit argocd-config/base/kustomization.yaml
$ edit argocd-config/overlays/${ENV}/kustomization.yaml
Tests should be written using ginkgo
and gomega
as follows:
$ edit ${APP_NAME}/test/suite_test.go
$ edit ${APP_NAME}/test/some_test.go
Add the new test to TESTS
in test/Makefile
.
Argo CD in staging environments refers to stage
branch.
CircleCI will create a pull request to update stage
branch
when main
branch is updated.
Argo CD in production environments refers to release
branch.
When stage
branch is updated, CircleCI creates a pull request to
update release
stage to propagate the same set of changes.
Make sure you are logging in Argo CD.
When argocd app list
shows OutOfSync
status for an application as follows:
$ argocd app list
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS
argocd-config https://kubernetes.default.svc argocd default Synced Healthy <none> <none>
metallb https://kubernetes.default.svc metallb-system default Synced Progressing <none> <none>
monitoring https://kubernetes.default.svc monitoring default OutOfSync Missing <none> <none>
Try manual synchronization or investigate further details:
$ argocd app sync monitoring
$ argocd app get monitoring
Or use kubectl describe
for Kubernetes resources:
$ kubectl describe -n monitoring deployment alertmanager