Skip to content

Instantly share code, notes, and snippets.

View GloriaPG's full-sized avatar

Gloria Palma GloriaPG

View GitHub Profile
@GloriaPG
GloriaPG / CronJob.yaml
Last active May 12, 2020 22:46
CronJob for delete pod
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: deleting-pods
namespace: my-namespace
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
@GloriaPG
GloriaPG / pv-pvc-pod.txt
Last active November 14, 2019 19:14
Ejemplo de PV, PVC montado en un pod
vi pv.yaml
kind: PersistentVolume
apiVersion: v1
metadata:
name: myvolume
spec:
storageClassName: normal
capacity:
storage: 10Gi
@GloriaPG
GloriaPG / mvp.txt
Created November 14, 2019 18:45
Montar volumen en un poc
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
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:
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:
@GloriaPG
GloriaPG / svc-deployment.txt
Last active November 14, 2019 18:22
Exponer como servicio un deployment
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
@GloriaPG
GloriaPG / svpod.txt
Created November 14, 2019 17:56
Secrets como variables de entorno
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
@GloriaPG
GloriaPG / svp.txt
Created November 14, 2019 17:53
Secrets como volúmenes
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
@GloriaPG
GloriaPG / secrets-file.txt
Created November 14, 2019 17:50
Secrets como archivos
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
@GloriaPG
GloriaPG / cm-volume.txt
Created November 14, 2019 17:41
Pods & ConfigMap: Volúmenes
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