diff --git a/yaml-del-pelado/01-pod.yaml b/yaml-del-pelado/01-pod.yaml new file mode 100644 index 0000000..1e02173 --- /dev/null +++ b/yaml-del-pelado/01-pod.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx +spec: + containers: + - name: nginx + image: nginx:alpine diff --git a/yaml-del-pelado/02-pod.yaml b/yaml-del-pelado/02-pod.yaml new file mode 100644 index 0000000..62c43a4 --- /dev/null +++ b/yaml-del-pelado/02-pod.yaml @@ -0,0 +1,37 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx +spec: + containers: + - name: nginx + image: nginx:alpine + env: + - name: MI_VARIABLE + value: "pelado" + - name: MI_OTRA_VARIABLE + value: "pelade" + - name: DD_AGENT_HOST + valueFrom: + fieldRef: + fieldPath: status.hostIP + resources: + requests: + memory: "64Mi" + cpu: "200m" + limits: + memory: "128Mi" + cpu: "500m" + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 15 + periodSeconds: 20 + ports: + - containerPort: 80 diff --git a/yaml-del-pelado/03-daemonset.yaml b/yaml-del-pelado/03-daemonset.yaml new file mode 100644 index 0000000..6535592 --- /dev/null +++ b/yaml-del-pelado/03-daemonset.yaml @@ -0,0 +1,45 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: nginx-deployment +spec: + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:alpine + env: + - name: MI_VARIABLE + value: "pelado" + - name: MI_OTRA_VARIABLE + value: "pelade" + - name: DD_AGENT_HOST + valueFrom: + fieldRef: + fieldPath: status.hostIP + resources: + requests: + memory: "64Mi" + cpu: "200m" + limits: + memory: "128Mi" + cpu: "500m" + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 15 + periodSeconds: 20 + ports: + - containerPort: 80 diff --git a/yaml-del-pelado/04-deployment.yaml b/yaml-del-pelado/04-deployment.yaml new file mode 100644 index 0000000..fecf341 --- /dev/null +++ b/yaml-del-pelado/04-deployment.yaml @@ -0,0 +1,46 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + selector: + matchLabels: + app: nginx + replicas: 2 + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:alpine + env: + - name: MI_VARIABLE + value: "pelado" + - name: MI_OTRA_VARIABLE + value: "pelade" + - name: DD_AGENT_HOST + valueFrom: + fieldRef: + fieldPath: status.hostIP + resources: + requests: + memory: "64Mi" + cpu: "200m" + limits: + memory: "128Mi" + cpu: "500m" + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 15 + periodSeconds: 20 + ports: + - containerPort: 80 diff --git a/yaml-del-pelado/05-statefulset.yaml b/yaml-del-pelado/05-statefulset.yaml new file mode 100644 index 0000000..315be67 --- /dev/null +++ b/yaml-del-pelado/05-statefulset.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: my-csi-app-set +spec: + selector: + matchLabels: + app: mypod + serviceName: "my-frontend" + replicas: 1 + template: + metadata: + labels: + app: mypod + spec: + containers: + - name: my-frontend + image: busybox + args: + - sleep + - infinity + volumeMounts: + - mountPath: "/data" + name: csi-pvc + volumeClaimTemplates: + - metadata: + name: csi-pvc + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi + storageClassName: do-block-storage diff --git a/yaml-del-pelado/06-randompod.yaml b/yaml-del-pelado/06-randompod.yaml new file mode 100644 index 0000000..3408547 --- /dev/null +++ b/yaml-del-pelado/06-randompod.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Pod +metadata: + name: ubuntu +spec: + containers: + - name: ubuntu + image: ubuntu + args: + - sleep + - infinity diff --git a/yaml-del-pelado/07-hello-deployment-svc-clusterIP.yaml b/yaml-del-pelado/07-hello-deployment-svc-clusterIP.yaml new file mode 100644 index 0000000..9d41c36 --- /dev/null +++ b/yaml-del-pelado/07-hello-deployment-svc-clusterIP.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello +spec: + replicas: 3 + selector: + matchLabels: + role: hello + template: + metadata: + labels: + role: hello + spec: + containers: + - name: hello + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 + +--- +apiVersion: v1 +kind: Service +metadata: + name: hello +spec: + ports: + - port: 8080 + targetPort: 8080 + selector: + role: hello diff --git a/yaml-del-pelado/08-hello-deployment-svc-nodePort.yaml b/yaml-del-pelado/08-hello-deployment-svc-nodePort.yaml new file mode 100644 index 0000000..46c9149 --- /dev/null +++ b/yaml-del-pelado/08-hello-deployment-svc-nodePort.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello +spec: + replicas: 3 + selector: + matchLabels: + role: hello + template: + metadata: + labels: + role: hello + spec: + containers: + - name: hello + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 + +--- +apiVersion: v1 +kind: Service +metadata: + name: hello +spec: + type: NodePort + ports: + - port: 8080 + targetPort: 8080 + nodePort: 30000 + selector: + role: hello diff --git a/yaml-del-pelado/09-hello-deployment-svc-loadBalancer.yaml b/yaml-del-pelado/09-hello-deployment-svc-loadBalancer.yaml new file mode 100644 index 0000000..3c07845 --- /dev/null +++ b/yaml-del-pelado/09-hello-deployment-svc-loadBalancer.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello +spec: + replicas: 3 + selector: + matchLabels: + role: hello + template: + metadata: + labels: + role: hello + spec: + containers: + - name: hello + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 + +--- +apiVersion: v1 +kind: Service +metadata: + name: hello +spec: + type: LoadBalancer + ports: + - port: 8080 + targetPort: 8080 + selector: + role: hello diff --git a/yaml-del-pelado/10-hello-v1-v2-deployment-svc.yaml b/yaml-del-pelado/10-hello-v1-v2-deployment-svc.yaml new file mode 100644 index 0000000..d222bae --- /dev/null +++ b/yaml-del-pelado/10-hello-v1-v2-deployment-svc.yaml @@ -0,0 +1,65 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-v1 +spec: + replicas: 3 + selector: + matchLabels: + role: hello-v1 + template: + metadata: + labels: + role: hello-v1 + spec: + containers: + - name: hello-v1 + image: gcr.io/google-samples/hello-app:1.0 + ports: + - containerPort: 8080 + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-v2 +spec: + replicas: 3 + selector: + matchLabels: + role: hello-v2 + template: + metadata: + labels: + role: hello-v2 + spec: + containers: + - name: hello-v2 + image: gcr.io/google-samples/hello-app:2.0 + ports: + - containerPort: 8080 + +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-v1 +spec: + ports: + - port: 8080 + targetPort: 8080 + selector: + role: hello-v1 + +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-v2 +spec: + ports: + - port: 8080 + targetPort: 8080 + selector: + role: hello-v2 diff --git a/yaml-del-pelado/11-hello-ingress.yaml b/yaml-del-pelado/11-hello-ingress.yaml new file mode 100644 index 0000000..89cc161 --- /dev/null +++ b/yaml-del-pelado/11-hello-ingress.yaml @@ -0,0 +1,22 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: hello-app +spec: + rules: + - http: + paths: + - path: /v1 + pathType: Prefix + backend: + service: + name: hello-v1 + port: + number: 8080 + - path: /v2 + pathType: Prefix + backend: + service: + name: hello-v2 + port: + number: 8080 diff --git a/yaml-del-pelado/12-configmap.yaml b/yaml-del-pelado/12-configmap.yaml new file mode 100644 index 0000000..4b229f0 --- /dev/null +++ b/yaml-del-pelado/12-configmap.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: game-demo +data: + # property-like keys; each key maps to a simple value + player_initial_lives: "3" + ui_properties_file_name: "user-interface.properties" + # + # file-like keys + game.properties: | + enemy.types=aliens,monsters + player.maximum-lives=5 + user-interface.properties: | + color.good=purple + color.bad=yellow + allow.textmode=true diff --git a/yaml-del-pelado/13-pod-configmap.yaml b/yaml-del-pelado/13-pod-configmap.yaml new file mode 100644 index 0000000..2619839 --- /dev/null +++ b/yaml-del-pelado/13-pod-configmap.yaml @@ -0,0 +1,33 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx +spec: + containers: + - name: nginx + image: nginx:alpine + env: + # Define the environment variable + - name: PLAYER_INITIAL_LIVES # Nombre de la variable + valueFrom: + configMapKeyRef: + name: game-demo # El confimap desde donde vienen los valores + key: player_initial_lives # La key que vamos a usar + - name: UI_PROPERTIES_FILE_NAME + valueFrom: + configMapKeyRef: + name: game-demo + key: ui_properties_file_name + volumeMounts: + - name: config + mountPath: "/config" + readOnly: true + volumes: + - name: config + configMap: + name: game-demo # el nombre del configmap que queremos montar + items: # Un arreglo de keys del configmap para crear como archivos + - key: "game.properties" + path: "game.properties" + - key: "user-interface.properties" + path: "user-interface.properties" diff --git a/yaml-del-pelado/14-secret.yaml b/yaml-del-pelado/14-secret.yaml new file mode 100644 index 0000000..b4cd583 --- /dev/null +++ b/yaml-del-pelado/14-secret.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: db-credentials +type: Opaque +data: + username: YWRtaW4= + password: c3VwM3JwYXNzdzByZAo= + +# Esto se puede crear a mano: +# kubectl create secret generic db-credentials --from-literal=username=admin --from-literal=password=sup3rpassw0rd +# Docs: https://kubernetes.io/es/docs/concepts/configuration/secret/ diff --git a/yaml-del-pelado/15-pod-secret.yaml b/yaml-del-pelado/15-pod-secret.yaml new file mode 100644 index 0000000..ec74cf4 --- /dev/null +++ b/yaml-del-pelado/15-pod-secret.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx +spec: + containers: + - name: nginx + image: nginx:alpine + env: + - name: MI_VARIABLE + value: "pelado" + - name: MYSQL_USER + valueFrom: + secretKeyRef: + name: db-credentials + key: username + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: db-credentials + key: password + ports: + - containerPort: 80 diff --git a/yaml-del-pelado/kustomization.yaml b/yaml-del-pelado/kustomization.yaml new file mode 100644 index 0000000..4be5001 --- /dev/null +++ b/yaml-del-pelado/kustomization.yaml @@ -0,0 +1,18 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +commonLabels: + app: ejemplo + +resources: +- 15-pod-secret.yaml + +secretGenerator: +- name: db-credentials + literals: + - username=admin + - password=secr3tpassw0rd! + +images: +- name: nginx + newTag: latest