Diferències
Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
Següent revisió | Revisió prèvia | ||
info:cursos:pue:devops:sesion12 [23/03/2019 01:35] – creat mate | info:cursos:pue:devops:sesion12 [08/04/2020 06:59] (actual) – mate | ||
---|---|---|---|
Línia 1: | Línia 1: | ||
- | = Sesión 12 : k8s | + | = Sesión 12 : k8s (traefik) |
+ | {{tag> | ||
== k8s | == k8s | ||
+ | === lab (traefik) | ||
* traefik como ingress controller:< | * traefik como ingress controller:< | ||
--- | --- | ||
Línia 160: | Línia 162: | ||
</ | </ | ||
+ | === lab (who) | ||
+ | [[https:// | ||
+ | |||
+ | <code yaml; whoami-deployment.yaml> | ||
+ | apiVersion: extensions/ | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | name: whoami-deployment | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: whoami | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: whoami | ||
+ | spec: | ||
+ | containers: | ||
+ | - name: whoami-container | ||
+ | image: containous/ | ||
+ | </ | ||
+ | |||
+ | <code yaml; whoami-service.yaml> | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: whoami-service | ||
+ | spec: | ||
+ | ports: | ||
+ | - name: http | ||
+ | targetPort: 80 | ||
+ | port: 80 | ||
+ | selector: | ||
+ | app: whoami | ||
+ | </ | ||
+ | |||
+ | <code yaml; whoami-ingress.yaml> | ||
+ | apiVersion: extensions/ | ||
+ | kind: Ingress | ||
+ | metadata: | ||
+ | name: whoami-ingress | ||
+ | annotations: | ||
+ | kubernetes.io/ | ||
+ | spec: | ||
+ | rules: | ||
+ | - host: whoami.localhost | ||
+ | http: | ||
+ | paths: | ||
+ | - path: / | ||
+ | backend: | ||
+ | serviceName: | ||
+ | servicePort: | ||
+ | </ | ||
+ | |||
+ | si queremos NO tocar el localhost para que resuelva **whoami.localhost**, | ||
+ | |||
+ | también podemos usar [[http:// | ||
+ | <code yaml; whoami-ingress.yaml> | ||
+ | apiVersion: extensions/ | ||
+ | kind: Ingress | ||
+ | metadata: | ||
+ | name: whoami-ingress | ||
+ | annotations: | ||
+ | kubernetes.io/ | ||
+ | spec: | ||
+ | rules: | ||
+ | - host: whoami-192-168-99-100.nip.io | ||
+ | http: | ||
+ | paths: | ||
+ | - path: / | ||
+ | backend: | ||
+ | serviceName: | ||
+ | servicePort: | ||
+ | </ | ||
+ | <code yaml; whoareyou-deployment.yaml> | ||
+ | apiVersion: extensions/ | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | name: whoareyou-deployment | ||
+ | spec: | ||
+ | replicas: 2 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: whoareyou | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: whoareyou | ||
+ | spec: | ||
+ | containers: | ||
+ | - name: whoareyou-container | ||
+ | image: containous/ | ||
+ | --- | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: whoareyou-service | ||
+ | spec: | ||
+ | ports: | ||
+ | - name: http | ||
+ | targetPort: 80 | ||
+ | port: 80 | ||
+ | selector: | ||
+ | app: whoareyou | ||
+ | --- | ||
+ | apiVersion: extensions/ | ||
+ | kind: Ingress | ||
+ | metadata: | ||
+ | name: whoareyou-ingress | ||
+ | annotations: | ||
+ | kubernetes.io/ | ||
+ | spec: | ||
+ | rules: | ||
+ | - host: whoareyou-192-168-99-100.nip.io | ||
+ | http: | ||
+ | paths: | ||
+ | - path: / | ||
+ | backend: | ||
+ | serviceName: | ||
+ | servicePort: | ||
+ | </ | ||
+ | |||
+ | === lab (flocker) | ||
+ | * '' | ||
+ | |||
+ | ==== instalar (sin flocker) un WP y MYSQL | ||
+ | * mysql:< | ||
+ | apiVersion: v1 | ||
+ | kind: Secret | ||
+ | metadata: | ||
+ | name: mysql-secret | ||
+ | type: Opaque | ||
+ | data: | ||
+ | password: cm9vdA== | ||
+ | </ | ||
+ | <code yaml; mysql.yaml> | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: wordpress-mysql | ||
+ | labels: | ||
+ | app: wordpress | ||
+ | spec: | ||
+ | ports: | ||
+ | - port: 3306 | ||
+ | selector: | ||
+ | app: wordpress | ||
+ | tier: mysql | ||
+ | clusterIP: None | ||
+ | --- | ||
+ | apiVersion: v1 | ||
+ | kind: PersistentVolumeClaim | ||
+ | metadata: | ||
+ | name: mysql-pv-claim | ||
+ | labels: | ||
+ | app: wordpress | ||
+ | spec: | ||
+ | accessModes: | ||
+ | - ReadWriteOnce | ||
+ | resources: | ||
+ | requests: | ||
+ | storage: 20Gi | ||
+ | --- | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | name: wordpress-mysql | ||
+ | labels: | ||
+ | app: wordpress | ||
+ | spec: | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: wordpress | ||
+ | tier: mysql | ||
+ | strategy: | ||
+ | type: Recreate | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: wordpress | ||
+ | tier: mysql | ||
+ | spec: | ||
+ | containers: | ||
+ | - image: mysql:5.6 | ||
+ | name: mysql | ||
+ | env: | ||
+ | - name: MYSQL_ROOT_PASSWORD | ||
+ | valueFrom: | ||
+ | secretKeyRef: | ||
+ | name: mysql-secret | ||
+ | key: password | ||
+ | ports: | ||
+ | - containerPort: | ||
+ | name: mysql | ||
+ | volumeMounts: | ||
+ | - name: mysql-persistent-storage | ||
+ | mountPath: / | ||
+ | volumes: | ||
+ | - name: mysql-persistent-storage | ||
+ | persistentVolumeClaim: | ||
+ | claimName: mysql-pv-claim | ||
+ | </ | ||
+ | <code yaml; wordpress.yaml> | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: wordpress-service | ||
+ | labels: | ||
+ | app: wordpress | ||
+ | spec: | ||
+ | ports: | ||
+ | - name: http | ||
+ | targetPort: 80 | ||
+ | port: 80 | ||
+ | # - port: 80 | ||
+ | selector: | ||
+ | app: wordpress | ||
+ | tier: frontend | ||
+ | # type: LoadBalancer | ||
+ | --- | ||
+ | apiVersion: v1 | ||
+ | kind: PersistentVolumeClaim | ||
+ | metadata: | ||
+ | name: wp-pv-claim | ||
+ | labels: | ||
+ | app: wordpress | ||
+ | spec: | ||
+ | accessModes: | ||
+ | - ReadWriteOnce | ||
+ | resources: | ||
+ | requests: | ||
+ | storage: 20Gi | ||
+ | --- | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | name: wordpress | ||
+ | labels: | ||
+ | app: wordpress | ||
+ | spec: | ||
+ | # replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: wordpress | ||
+ | tier: frontend | ||
+ | # strategy: | ||
+ | # type: Recreate | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: wordpress | ||
+ | tier: frontend | ||
+ | spec: | ||
+ | containers: | ||
+ | - image: wordpress: | ||
+ | name: wordpress | ||
+ | env: | ||
+ | - name: WORDPRESS_DB_HOST | ||
+ | value: wordpress-mysql | ||
+ | - name: WORDPRESS_DB_PASSWORD | ||
+ | valueFrom: | ||
+ | secretKeyRef: | ||
+ | name: mysql-secret | ||
+ | key: password | ||
+ | ports: | ||
+ | - containerPort: | ||
+ | name: wordpress | ||
+ | volumeMounts: | ||
+ | - name: wordpress-persistent-storage | ||
+ | mountPath: / | ||
+ | volumes: | ||
+ | - name: wordpress-persistent-storage | ||
+ | persistentVolumeClaim: | ||
+ | claimName: wp-pv-claim | ||
+ | --- | ||
+ | apiVersion: extensions/ | ||
+ | kind: Ingress | ||
+ | metadata: | ||
+ | name: wordpress-ingress | ||
+ | annotations: | ||
+ | kubernetes.io/ | ||
+ | spec: | ||
+ | rules: | ||
+ | - host: wordpress-192-168-99-100.nip.io | ||
+ | http: | ||
+ | paths: | ||
+ | - path: / | ||
+ | backend: | ||
+ | serviceName: | ||
+ | servicePort: | ||
+ | </ | ||
+ | |||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * lo que no se muestra: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ==== flocker | ||
+ | * instalación: | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | == objetos kubernetes | ||
+ | * replicationcontroller: | ||
+ | * replicaset: [[https:// | ||
+ | * deployment: [[https:// | ||
+ | * rollout, concepto de log de revisiones de deployment | ||
+ | * sección deployment, sección replicaset, sección pod | ||
+ | * daemonset: [[https:// | ||
+ | * statefulsets: | ||
+ | * storageclassname : servicio de gestión de volúmenes | ||
+ | * persistentvolumes: | ||
+ | * modos: | ||
+ | * readWriteOnce : solo un POD puede usar ese volumen para lectura/ | ||
+ | * readOnlyMany | ||
+ | * readWriteMany | ||
+ | * persistentVolumeProvisioning: | ||
+ | * storage classes: [[https:// | ||
+ | * secrets: [[https:// | ||
+ | * labels: [[https:// | ||
+ | == otros | ||
+ | * '' |