Skip to content

Latest commit

 

History

History
125 lines (108 loc) · 2.72 KB

File metadata and controls

125 lines (108 loc) · 2.72 KB

KUBECTL

Contexts

Contexts are defined in your .kube/config file

Show available Contexts

kubectl config get-contexts

Get Current Context

kubectl config current-context

Set Current Contexts

kubectl config set current-context [Context]

Basics

Show pods

kubectl -n [namespace] get pods

Describe a pod

kubectl -n [namespace] describe pods [podname]

View container logs (with tail)

kubectl -n monitoring logs --tail 100  pods/ingress-nginx-thanos-grpc-controller-5d6b76f7c7-hvq4x -f

View configmaps

kubectl -n monitoring describe configmaps ingress-nginx-thanos-grpc-controller

Describe Ingress

kubectl -n monitoring describe ingress thanos-grpc

Get Services

kubectl -n monitoring get service

Local Port Forward

kubectl -n monitoring port-forward pods/thanos-querier-59d64746cd-6plhh 10901:10901

Restart a pod

kubeclt -n monitoring delete [pod]

Deployments

Show deployments for a namespace

kubectl -n monitoring get deployment

Perform a Rolling restart of a deployments

kubectl -n monitoring rollout restart deployment [deployment]

Exec Commands In a container.

View nginix ingress config

kubectl exec -it -n monitoring ingress-nginx-thanos-grpc-controller-5d6b76f7c7-hvq4x -- cat /etc/nginx/nginx.conf

Open a shell in the container

kubectl exec -it -n monitoring ingress-nginx-thanos-grpc-controller-5d6b76f7c7-hvq4x -- /bin/sh

Kubernetes Secrets

SSL Cert Example

kubectl -n [namespace] create secret tls [secret name] --key [file with key] --cert [file with cert]

File Example Yaml file containing AWS S3 Credentials

type: S3
config:
  bucket: bucket
  endpoint: s3.us-west-2.amazonaws.com
  region: [region]
  access_key: xxxxxxxxx
  insecure: false
  signature_version2: false
  secret_key: xxxxxxx

Create Secret Example

kubectl -n monitoring create secret generic thanos-objstore-config --from-file=objstore.yml=/path/to/yaml/in/git/storage-secret.yaml

Update Secret update the keys in the yaml

kubectl -n monitoring create secret generic thanos-objstore-config --from-file=objstore.yml=/path/to/yaml/in/git/storage-secret.yaml --dry-run -o yaml | kubectl apply -f -

HELM

helm deploy

helm upgrade [realease] [chart] [flags]

Examples: Thanos

  • in git location for values file (eg. Magnite/helm-bitnami_thanos_values)
helm upgrade thanos helm-bitnami/thanos --install -n monitoring -f values/dev/las2.yaml --version 2.3.4

Nginx ingress

helm upgrade ingress-nginx-thanos-grpc helm-github.io-kubernetes-ingress-nginx/ingress-nginx --install -n monitoring -f values/dev/las2.yaml --version 3.7.1