0% found this document useful (0 votes)
194 views

Kubernetes Cheat Sheet

This document provides a cheatsheet for common Kubernetes CLI commands. It includes sections on CLI setup, managing contexts and namespaces, deploying and exposing applications, debugging and retrieving logs, configuring ingress, and managing storage volumes. Examples are given for commands to create and manage deployments, services, pods, and configurations.

Uploaded by

Aishu Naidu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views

Kubernetes Cheat Sheet

This document provides a cheatsheet for common Kubernetes CLI commands. It includes sections on CLI setup, managing contexts and namespaces, deploying and exposing applications, debugging and retrieving logs, configuring ingress, and managing storage volumes. Examples are given for commands to create and manage deployments, services, pods, and configurations.

Uploaded by

Aishu Naidu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Cheatsheet

version 2020-11-15 EN

# CLI setup # Create a deployment named web, using image nginx into prod namespace
CLI tools

https://ibd.sh/kubectl kubectl create -n prod deploy web --image=nginx


https://ibd.sh/kubectx # Expose port 80 of deployment web with an internal service named front
https://ibd.sh/kubetail kubectl expose deploy/web --port=80 --name=front

deploy / expose
https://ibd.sh/helm
# Retrieve logs of pods with tag app=web
kubetail -l app=web
# List available contexts
contexts

kubectx # Open a tunnel listening on 127.0.0.1:8080 to the port 80 of a pod related to deployment web
kubectl port-forward deploy/web 8080:80
# Change context to dev
kubectx dev # Create a Yaml manifest, without sending it to the cluster
kubectl create deploy web --image=nginx --dry-run=client -o yaml > web.yml

# List namespaces # Edit deployment web


kubectl edit deploy/web
namespaces

kubens
# Change namespace to prod # Retrieve detailed state of pod test # PVC manifest example

storage / volume
kubens prod kubectl describe pod test kind: PersistentVolumeClaim
help / debug

apiVersion: v1
# Create namespace test # Get all possible attributes of a resource metadata:
kubectl create ns test name: web-data
kubectl explain pod --recursive spec:
accessModes:
# Open a bash terminal in pod app
# Ingress manifest example - ReadWriteOnce
apiVersion: networking.k8s.io/v1 kubectl exec -it app -- bash resources:
kind: Ingress requests:
metadata:
name: test-ingress
# NB : The flag --help provide help of any command storage: 42Gi
spec:
rules:
ingress

- host: foo.bar.com # Use the config file /path/to/config rather than ~/.kube/config

Web : infraBuilder.com
Command cheasheet

by Alexis DUCASTEL
forr Kubernetes 1.19
http:
configuration

paths:
- path: /testpath
export KUBECONFIG=/path/to/config
backend:
service: # Merge two configuration files config1 and config2 in one file config
name: test
port: KUBECONFIG=config1:config2 kubectl config view --flatten > config
number: 80
tls:
- hosts:
# Export only the current context configuration to file config
- foo.bar.com
secretName: foobar-tls
kubectl config view --minify --flatten > config

You might also like