Howto use ACM

  • Presuming that steps followed to deploy ACM, this guide focuses on how to use ACM

Check that all pods are running

kubectl get pods -n config-management-system --show-labels

Download nomos for your OS - Linux, OSX, Windows

https://cloud.google.com/anthos-config-management/downloads

Create SSH Key for ACM

ssh-keygen -t rsa -b 4096 -C "Anthos ACM Key" -N '' -f ./anthos-acm-key
kubectl create secret generic git-creds \
 --namespace=config-management-system \
 --from-file=ssh=./anthos-acm-key

Register Key here - cat anthos-acm-key.pub

https://source.cloud.google.com/user/ssh_keys

Confirm authentication

$ ssh -v -T -l <username@domain>@source.developers.google.com -i ./anthos-acm-key -p 2022

Source Code repo

https://source.cloud.google.com//acm-demo

Create a cloud source repo:

gcloud source repos create acm-demo
Clone the repository and change directory into the cloned repo:
gcloud source repos clone acm-demo
cd acm-demo

Initialize the repository using nomos

  • This creates the basic directory structure used by the Anthos Configuration Management operator.
  • Specifically, this creates the ./system, ./cluster, ./clusteregistry, and ./namespaces directories.
mkdir acm-demo
cd acm-demo
nomos init
cat > acm-demo/namespaces/production>prod-ns.yaml <<EOF
apiVersion: v1
kind: Namespace
metadata:
  name: production
EOF
cat > acm-demo/system/repo.yaml <<EOF
apiVersion: configmanagement.gke.io/v1
kind: Repo
metadata:
  creationTimestamp: null
  name: repo
spec:
  version: 1.0.0
status:
  import:
    lastUpdate: null
  source: {}
  sync:
    lastUpdate: null
EOF

Add all new/changed files to the cloned repo, commit with a message, and push the change to the master branch:

git add .
git commit -m 'Adding initial files for nomos'
git push

Watch namespace, Delete namespace, See namespace come back to life

# Run these commands in separate terminals
kubectl get ns --watch
kubectl delete ns production

Check logs for troubleshooting

kubectl logs -n config-management-system -l app=git-importer -c importer
kubectl logs --selector app=syncer -n config-management-system --tail=10000
kubectl logs --selector app=monitor -n config-management-system --tail=10000
kubectl logs --selector app=git-importer -n config-management-system

Change the git-repo that my acm is pointing

kubectl edit ConfigManagement config-management

https://github.com/GoogleCloudPlatform/gke-anthos-holistic-demo/blob/master/anthos/README.md