Skip to content

Kubernetes

How-to Guide

Access k8s without azure cli

  • Make sure that you have kubectl
  • Download the kube.config file:

    • Inside GitLab: go to CI/CD > Jobs
    • search for the cluster:apply job (if there is none, go to Next page)
    • Click on Download artifacts (inside the Coverage column)
    • extract content into $HOME/.kube/config or %USERPROFILE%\.kube\config
    • (optional) If you want to use it inside WSL run:
      ln -s /mnt/c/Users/<username>/.kube $HOME/.kube
    
    • (optional) get rid of the security warnings:
      chmod -R -c 744 .kube
    

Global logging using stern

Stern allows you to tail multiple pods on Kubernetes. Each result is color coded for quicker debugging.

Here you can find a logger script that jointly monitors pods from the relevant namespaces from both the main and the external cluster (incl. Broker, FlashVaults, Provider and Consumer). For help on the usage run ./global_logger.sh -h within the scripts folder.

To run the script, you will need to install stern. On Windows, you can do that by simply downloading stern.exe into a dedicated folder and adding it to your Path variable. For installing stern on other operating systems or for a custom logging setup you may consult stern's GitHub page .

Access k8s with azure cli

  • Additionally install azure cli
  • Go to the azure portal where the Kubernetes is hosted
  • Choose the k8s cluster you want to connect to
  • Click on connect (which is just below the name of the cluster)
  • Follow the steps in the tutorial

  • Get pods: kubectl get pods optional: get pods with their IP addresses: kubectl get pods -o wide

  • Get pods in another namespace: kubectl get pods -n <namespace>
  • Get services: kubectl get services
  • Get pod logs: kubectl logs <pod>
  • Get deployments logs: kubectl logs deployment/<deployment_name>
  • Get ingress address (e.g. for e2e tests): kubectl get ingress
  • Set a namespace as default for kubectl calls: kubectl config set-context --current --namespace=<namespace>
  • Troubleshoot non-starting pods: kubectl describe pod <pod>
  • Start and access a debugging container on kubernetes: https://docs.microsoft.com/en-us/azure/aks/ssh
  • Remove namespace and its contents: kubectl delete ns <namespace>
  • Write file contents to a bash variable (useful for mounting files): export VAR_CONTENT=$(cat $VAR_LOCATION)
  • Write file with windows line endings: export VAR_CONTENT=$(cat $VAR_LOCATION | dos2unix)
  • Forward Ports from inside pods:
  kubectl port-forward -n <namespace> <pod> <local_port>:<pod_port>
  • Ssh into pod: kubectl -n <namespace> exec <pod> -it -- bash

Access Kubernetes Dashboard

The Kubernetes-Dashboard is deployed from the official Kubernetes-Dashboard Helm Chart , and it can be accessed by following these steps:

  • Start the proxy to the Kubernetes api: kubectl proxy
  • Open http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:https/proxy/
  • Login by uploading the kube config that can be obtained as artifact of the cluster:save_credentials CICD pipeline job.