Explorar o código

add probes materials

Grega Bremec hai 7 meses
pai
achega
c7445f290b
Modificáronse 3 ficheiros con 178 adicións e 0 borrados
  1. 66 0
      labs/health/probes/application.yaml
  2. 37 0
      playbooks/probes-finish.yml
  3. 75 0
      playbooks/probes-start.yml

+ 66 - 0
labs/health/probes/application.yaml

@@ -0,0 +1,66 @@
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  labels:
+    app: expense
+    app.kubernetes.io/component: expense
+    app.kubernetes.io/instance: expense
+  name: expense
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      deployment: expense
+  strategy: {}
+  template:
+    metadata:
+      labels:
+        deployment: expense
+    spec:
+      containers:
+      - image: quay.io/redhattraining/ocpdev-expense-service-health:4.14
+        imagePullPolicy: Always
+        name: expense
+        ports:
+        - containerPort: 8080
+          protocol: TCP
+        resources:
+          requests:
+            memory: "50Mi"
+          limits:
+            memory: "50Mi"
+---
+apiVersion: v1
+kind: Service
+metadata:
+  labels:
+    app: expense
+    app.kubernetes.io/component: expense
+    app.kubernetes.io/instance: expense
+  name: expense
+spec:
+  ports:
+  - name: 8080-tcp
+    port: 8080
+    protocol: TCP
+    targetPort: 8080
+  selector:
+    deployment: expense
+---
+apiVersion: route.openshift.io/v1
+kind: Route
+metadata:
+  labels:
+    app: expense
+    app.kubernetes.io/component: expense
+    app.kubernetes.io/instance: expense
+  name: expense
+spec:
+  host: expense-deployments-health.apps.ocp4.example.com
+  port:
+    targetPort: 8080-tcp
+  to:
+    kind: Service
+    name: expense
+    weight: 100

+ 37 - 0
playbooks/probes-finish.yml

@@ -0,0 +1,37 @@
+---
+- name: Clean up after the strategies exercise
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  vars:
+    ge_nsp: deployments-health
+  tasks:
+    - name: Make sure kubeconfig is there on utility
+      delegate_to: utility.lab.example.com
+      file:
+        path: /home/lab/{{ item }}/auth/kubeconfig
+        state: file
+      loop: "{{ clusters }}"
+
+    - name: Create a temp dir
+      file:
+        path: tmp
+        state: directory
+
+    - name: Copy over the kubeconfig
+      delegate_to: utility.lab.example.com
+      fetch:
+        src: /home/lab/{{ item }}/auth/kubeconfig
+        dest: tmp/kubeconfig-{{ item }}
+        flat: yes
+      loop: "{{ clusters }}"
+
+    - name: Ensure the namespace for the exercise is gone
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+        state: absent
+...

+ 75 - 0
playbooks/probes-start.yml

@@ -0,0 +1,75 @@
+---
+- name: Prepare for the strategies exercise
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  vars:
+    ge_nsp: deployments-health
+  tasks:
+    - name: Make sure kubeconfig is there on utility
+      delegate_to: utility.lab.example.com
+      file:
+        path: /home/lab/{{ item }}/auth/kubeconfig
+        state: file
+      loop: "{{ clusters }}"
+
+    - name: Create a temp dir
+      file:
+        path: tmp
+        state: directory
+
+    - name: Copy over the kubeconfig
+      delegate_to: utility.lab.example.com
+      fetch:
+        src: /home/lab/{{ item }}/auth/kubeconfig
+        dest: tmp/kubeconfig-{{ item }}
+        flat: yes
+      loop: "{{ clusters }}"
+
+    - name: Check whether the namespace is already there
+      k8s_info:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+      register: ge_exists
+
+    - name: Fail if the namespace exists
+      fail:
+        msg: "The exercise namespace already exists: {{ ge_nsp }}; please run strategy-finish.yml to clean up first and then re-run this playbook."
+      when: ge_exists.resources | length > 0
+
+    - name: Ensure there is a namespace for the exercise
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+
+    - name: Give developer admin role in the project
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: rbac.authorization.k8s.io/v1
+        kind: rolebinding
+        namespace: "{{ ge_nsp }}"
+        name: dev-admin
+        definition:
+          roleRef:
+            apiGroup: rbac.authorization.k8s.io
+            kind: ClusterRole
+            name: admin
+          subjects:
+          - apiGroup: rbac.authorization.k8s.io
+            kind: User
+            name: developer
+
+    - name: Deploy the sample app manifest
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        namespace: "{{ ge_nsp }}"
+        src: ../labs/health/probes/application.yaml
+