This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
kind: ServiceAccount | |
apiVersion: v1 | |
metadata: | |
name: deleting-pods | |
namespace: my-namespace | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: Role |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vi pv.yaml | |
kind: PersistentVolume | |
apiVersion: v1 | |
metadata: | |
name: myvolume | |
spec: | |
storageClassName: normal | |
capacity: | |
storage: 10Gi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl run busybox --image=busybox --restart=Never -o yaml --dry-run -- /bin/sh -c 'sleep 3600' > pod.yaml | |
vi pod.yaml | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: busybox | |
name: busybox |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl run nginx --image=nginx --replicas=2 --port=80 --expose | |
kubectl describe svc nginx # see the 'run=nginx' selector for the pods | |
# or | |
kubectl get svc nginx -o yaml --export | |
vi policy.yaml | |
kind: NetworkPolicy | |
apiVersion: networking.k8s.io/v1 | |
metadata: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl run nginx --image=nginx --replicas=2 --port=80 --expose | |
kubectl describe svc nginx # see the 'run=nginx' selector for the pods | |
# or | |
kubectl get svc nginx -o yaml --export | |
vi policy.yaml | |
kind: NetworkPolicy | |
apiVersion: networking.k8s.io/v1 | |
metadata: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl run foo --image=dgkanatsios/simpleapp --labels=app=foo --port=8080 --replicas=3 | |
kubectl get pods -l app=foo -o wide # 'wide' will show pod IPs | |
kubectl run busybox --image=busybox --restart=Never -it --rm -- sh | |
wget -O- POD_IP:8080 # do not try with pod name, will not work | |
# try hitting all IPs to confirm that hostname is different | |
exit | |
kubectl expose deploy foo --port=6262 --target-port=8080 | |
kubectl get service foo # you will see ClusterIP as well as port 6262 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl delete po nginx | |
kubectl run nginx --image=nginx --restart=Never -o yaml --dry-run > pod.yaml | |
vi pod.yaml | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl run nginx --image=nginx --restart=Never -o yaml --dry-run > pod.yaml | |
vi pod.yaml | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: nginx | |
name: nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo admin > username | |
kubectl create secret generic mysecret2 --from-file=username | |
kubectl get secret mysecret2 -o yaml --export | |
echo YWRtaW4K | base64 -d | |
Otra opción para ver los valores de un secreet. | |
kubectl get secret mysecret2 -o jsonpath='{.data.username}{"\n"}' | base64 -d | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl create configmap cmvolume --from-literal=var8=val8 --from-literal=var9=val9 | |
kubectl run nginx --image=nginx --restart=Never -o yaml --dry-run > pod.yaml | |
vi pod.yaml | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: nginx | |
name: nginx |
NewerOlder