Skip to content

Instantly share code, notes, and snippets.

@tacsio
Last active February 13, 2023 20:14
Show Gist options
  • Save tacsio/fe4e9d85362ee29ddbc57106583b87ca to your computer and use it in GitHub Desktop.
Save tacsio/fe4e9d85362ee29ddbc57106583b87ca to your computer and use it in GitHub Desktop.
# kubectl
cd /usr/local/bin/
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
cd -
#kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.14.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
#cluster kind
cat << EOF > $HOME/kind-cluster.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
EOF
kind create cluster --name cluster-kind --config $HOME/kind-cluster.yaml
kubectl get nodes
-------
## DAY 2
apiVersion: v1
kind: Pod
metadata:
name: nginx-giropops
labels:
run: nginx-giropops
app: giropops-strigus
spec:
containers:
- image: nginx
name: nginx-giropops
ports:
- containerPort: 80
resources:
requests:
cpu: "0.3"
memory: "128Mi"
limits:
cpu: "0.5"
memory: "400Mi"
---
## DAY 3
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx-girus
opa: sensacional-juvenal
name: nginx-girus
spec:
replicas: 2
selector:
matchLabels:
app: nginx-girus
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
app: nginx-girus
spec:
containers:
- image: nginx:1.16.0
name: nginx-girus
resources:
requests:
cpu: 0.5
memory: 64Mi
limits:
cpu: 0.7
memory: 128Mi
## Volume + Rolling Update
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nome-deploy
name: nome-deploy
spec:
replicas: 2
selector:
matchLabels:
app: nome-deploy
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2
maxUnavailable: 2
template:
metadata:
creationTimestamp: null
labels:
app: nome-deploy
spec:
containers:
- image: nginx:1.16.0
name: nome-deploy
volumeMounts:
- mountPath: /data
name: nome-volume
resources:
requests:
cpu: 0.5
memory: 64Mi
limits:
cpu: 0.7
memory: 128Mi
volumes:
- name: nome-volume
emptyDir:
sizeLimit: 256Mi
@tacsio
Copy link
Author

tacsio commented Jan 21, 2023

Scale a deployment “test” to 3 replicas:

kubectl scale deploy/test --replicas=3

Watch update status for deployment “test”:

kubectl rollout status deploy/test

Pause deployment on “test”:

kubectl rollout pause deploy/test

Resume deployment on “test”:

kubectl rollout resume deploy/test

View rollout history on “test”:

kubectl rollout history deploy/test

Undo most recent update on “test”:

kubectl rollout undo deploy/test

Rollback to specific revision on “test”:

kubectl rollout undo deploy/test --to-revision=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment