Requirements
Azure CIP account and access to the s189 subscription
- https://technical-guidance.education.gov.uk/infrastructure/hosting/azure-cip/#onboarding-users
- request s189 access from the devops team
azure-cli installed locally
kubectl installed locally
All examples below show qa usage and you should adapt accordingly.
There are several AKS clusters, but only 2 are relevant for publish services.
s189t01-tsc-test-aks
- in s189-teacher-services-cloud-test subscription
- in s189t01-tsc-ts-rg resource group
- contains bat-qa and bat-staging namespaces
- will hold publish review apps, publish-qa, publish-staging
- PIM self approval required
s189p01-tsc-production-aks
- in s189-teacher-services-cloud-production subscription
- in s189p01-tsc-pd-rg resource group
- contains bat-production namespace
- will hold publish-production and publish-sandbox
- PIM approval required
You need to activate the role in the desired cluster below: https://portal.azure.com/?Microsoft_Azure_PIMCommon=true#view/Microsoft_Azure_PIMCommon/ActivationMenuBlade/~/azurerbac
Example: Activate s189-teacher-services-cloud-test
. It will be approved automatically after a few seconds
$ az login
Get access credentials for a managed Kubernetes cluster (passing the environment name):
$ make production get-cluster-credentials
$ kubectl get namespaces
$ kubectl -n bat-qa get deployments
$ kubectl -n bat-qa get pods
Without tail:
$ kubectl -n bat-qa logs publish-qa-some-number
Tail:
$ kubectl -n bat-qa logs publish-qa-some-number -f
Logs from the ingress:
$ kubectl logs deployment/ingress-nginx-controller -f
Alternatively you can install kubetail and run:
$ kubetail -n bat-qa publish-qa-*
You can also get logs from a deployed app using make with logs:
$ make review logs PR_NUMBER=1234
$ make qa logs
$ kubectl -n bat-qa get deployments
$ kubectl -n bat-qa exec -ti deployment/publish-review-1234 -- sh
Alternatively you can enter directly on a pod:
$ kubectl -n bat-qa exec -ti publish-qa-some-number -- sh
You can run a rails console on a deployed app using make with console:
$ make review console PR_NUMBER=1234
$ make qa console
You can connect using ssh on a deployed app using make with shell or worker-shell:
$ make review shell PR_NUMBER=1234
$ make qa worker-shell
All pods in a namespace:
kubectl -n bat-qa top pod
All pods:
kubectl top pod -A
$ kubectl -n bat-qa describe pods publish-somenumber-of-the-pod
The app:
$ kubectl -n bat-qa scale deployment/publish-loadtest --replicas 2
kubectl -n bat-qa exec -ti publish-loadtest-some-pod-number -- bundle exec rails c
kubectl -n bat-qa exec -ti publish-loadtest-some-pod-number -- bundle exec rake -T
make install-konduit
bin/konduit.sh app-name -- psql
Example of loading test:
bin/konduit.sh publish-loadtest -- psql
For more info see Kubernetes cheatsheet