Skip to content

Latest commit

 

History

History
147 lines (111 loc) · 3.5 KB

kubernetes.md

File metadata and controls

147 lines (111 loc) · 3.5 KB

Kubernetes snippets

Further Information / Helpful stuff

Base64 Encoding

## Encode a String with base64:
echo -n 'blablabla' | base64

## Encode a File with base64:
base64 /path/to/file -w 0 > output.txt

Create Secret from whole file

kubectl create secret generic SECRET_NAME --from-file=path/to/file.env --dry-run=client -o yaml > mysecret.yaml

Sending stuff to the cluster

kubectl apply -f ./path/to/file.yaml -n namespace-name

Apply Argo Workflow to the cluster

## Send workflow to the cluster:
argo submit ./path/to/file.yaml --watch --log

## Create the workflow:
argo cron create ./path/to/file.yaml

Cheat Sheet

See https://kubernetes.io/docs/reference/kubectl/cheatsheet/.

Lens

LENS is a great platform to manage your cluster using a GUI. Give it a try.

Install KinD (Kubernetes in Docker)

KinD (Kubernetes in Docker) is a great way to test Kubernets stuff locally without the need of a high-performance cluster.

  1. Install KinD following the instructions on their webpage.

Install Argo (CD/Workflows)

## Add the repo for Argo:
helm repo add argo https://argoproj.github.io/argo-helm

## Install Argo Workflow with own presets:
helm install argo-wf argo/argo-workflows \
    --set controller.containerRuntimeExecutor=pns \
    --set workflow.rbac.create=true \
    --set workflow.namespace=default \
    --set workflow.serviceAccount.create=true

Context / Cluster switching

Show current Context

kubectl config current-context 

List all clusters available

kubectl config get-contexts

Set context to cluster

kubectl config use-context my-cluster-name

Set context within a HELM template

  {{with .Values.service}}
  type: {{ .type }}
  ports:
    - port: {{ .httpPort }}
      targetPort: http
      protocol: TCP
      name: patient-browser-server-http
  selector:
    {{- include "patient-browser.selectorLabels" $ | nindent 4 }}
  {{end}}

Templates

Secret

apiVersion: v1
kind: Secret
metadata:
  name: secret-name
type: Opaque
data:
  variable-key: variable-value

Persistent Volume Claim (PVC)

# Define Kubernetes PVC
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mydata
spec:
  storageClassName: "standard"
  accessModes: [ "ReadWriteOnce" ]
  resources:
    requests:
      storage: 1Gi