Introduction

This repo contains all the concepts useful to brush up your knowledge in enterprise software development and DevOps.

Links

https://kubernetes.io/docs/concepts/overview/components/ official docs, very useful overview

Commands

MISC

  • az acr build --resource-group <rg> --registry <acr> --image <image>:<tag> . upload image to registry

HELM

  • helm repo add bitnami https://charts.bitnami.com/bitnami add a helm repo
  • helm search repo bitnami list available images

Kubernetes

  • kubectl create secret to keep and spread secrets
  • kubectl get endpoints ratings-api --namespace ratingsapp see what you are exposing
  • kubectl config delete-context <context_name> clean kubeconfig context
  • kubectl config set-context <ctx_name> --namespace=<ns> create a new context
  • kubectl config use-context <ctx_name> use context as default
  • kubectl port-forward [<pod-name> or services/<service-name>] 8080:80 forward local traffic, to pod or load balancer
  • kubectl cp <pod-name>:<filepath> <filepath> copy file to local machine
  • kubectl cp $HOME/<filepath> <pod-name>:<filepath> copy file from remote machine
  • $ kubectl get deployments kuard --export -o yaml > kuard-deployment.yaml $ kubectl replace -f kuard-deployment.yaml --save-config export a deployment into a file and then store changes
  • kubectl run -i oneshot run a single job once
  • kubectl proxy similar to port forward, but instead of sending TCP traffic you send HTTP requests, port forward is for internal access and debugging, proxy is to forward traffic
  • kubectl top nodes top
  • kubectl expose deployment <my-deplo> To create a service
  • k get deploy kuard-deployment -o jsonpath --template {.spec.selector.matchLabels} Which labels is my deployment matching?
  • kubectl replace -f <filename> --save-config Replace the deployment in the file and save the modified config in its annotation
  • kubectl rollout status deployments <deployment-name> Check the rollout status
  • kubectl label <resource> ____
  • k create configmap test-config --from-file=test-config.txt --from-literal=extra-param=extra-value --from-literal=another-param=another-value Create ConfigMap
  • k create secret generic <name> --from-file=<filename> ____
  • kubectl replace -f - Read file from stdin and use it to replace a resource (fx. create with --dry-run -o yaml and then use this to update a secret from files on disk without having to manually base64-encode data)
  • kubectl auth can-i get pods --subresource=logs Can if I'm auth to do a verb
  • kubectl auth reconcile Reapply RBAC changes
  • kubectl run -it --rm --image busybox busybox ping <svc dns name> Run pod interactively and ping

Examples: KUARD_LB=$(kubectl get service kuard -o jsonpath='{.status.loadBalancer.ingress[*].hostname}') query a specific deployment for a parameter

Terraform

  • terraform init --backend-config="<key>=<value>" ____
  • terraform apply -var="<key>=<value>" pass sensitive variqables from command line
  • terraform show look the current state of the infrastructure
  • TF_VAR_<variable> this environment-variable can be set to set the terraform variable.
  • terraform state list list all resources provisioned via terraform
  • terraform plan -out=newplan write the plan into file, you can follow this with <terraform apply "newplan"
  • terraform validate spellcheck tf files
  • `` ____

Docker

  • docker run -d --name kuard --publish 8080:8080 gcr.io/kuar-demo/kuard-amd64:blue ____
  • docker stop kuard ____
  • docker system prune delete all untagged images, all stopped containers etc