Forráskód Böngészése

app deploy role & pbook

Grega Bremec 3 éve
szülő
commit
07cf8aad73

+ 11 - 0
deploy-apps.yml

@@ -0,0 +1,11 @@
+---
+- name: Make sure all secured clusters are federated
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  roles:
+#    - role: check-env
+#      tags: check
+    - role: deploy-apps
+      tags: deploy
+...

+ 32 - 0
roles/deploy-apps/files/k3s.yml

@@ -0,0 +1,32 @@
+---
+apiVersion: v1
+kind: List
+items:
+  - apiVersion: v1
+    kind: Namespace
+    metadata:
+      namespace: ''
+      name: test
+  - apiVersion: apps/v1
+    kind: Deployment
+    metadata:
+      labels:
+        app: php-hello
+      namespace: test
+      name: php-hello
+    spec:
+      replicas: 1
+      selector:
+        matchLabels:
+          app: php-hello
+      strategy: {}
+      template:
+        metadata:
+          labels:
+            app: php-hello
+        spec:
+          containers:
+          - image: quay.io/rhtuser/php-hello:ancient
+            name: php-hello
+            resources: {}
+...

+ 60 - 0
roles/deploy-apps/files/sno1.yml

@@ -0,0 +1,60 @@
+---
+apiVersion: v1
+kind: List
+items:
+  - apiVersion: v1
+    kind: Namespace
+    metadata:
+      namespace: ''
+      name: test
+  - apiVersion: image.openshift.io/v1
+    kind: ImageStream
+    metadata:
+      labels:
+        app: nginx-hello
+        app.kubernetes.io/component: nginx-hello
+        app.kubernetes.io/instance: nginx-hello
+      namespace: test
+      name: nginx-hello
+    spec:
+      lookupPolicy:
+        local: false
+      tags:
+      - annotations:
+          openshift.io/imported-from: quay.io/rhtuser/nginx-hello:ancient
+        from:
+          kind: DockerImage
+          name: quay.io/rhtuser/nginx-hello:ancient
+        importPolicy: {}
+        name: ancient
+        referencePolicy:
+          type: ""
+  - apiVersion: apps/v1
+    kind: Deployment
+    metadata:
+      annotations:
+        image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"nginx-hello:ancient"},"fieldPath":"spec.template.spec.containers[?(@.name==\"nginx-hello\")].image"}]'
+      labels:
+        app: nginx-hello
+        app.kubernetes.io/component: nginx-hello
+        app.kubernetes.io/instance: nginx-hello
+      namespace: test
+      name: nginx-hello
+    spec:
+      replicas: 1
+      selector:
+        matchLabels:
+          deployment: nginx-hello
+      strategy: {}
+      template:
+        metadata:
+          labels:
+            deployment: nginx-hello
+        spec:
+          containers:
+          - image: ' '
+            name: nginx-hello
+            ports:
+            - containerPort: 8080
+              protocol: TCP
+...

+ 14 - 0
roles/deploy-apps/tasks/main.yml

@@ -0,0 +1,14 @@
+---
+# assuming pre-flight had been executed so not doing any tests.
+- name: deploy the manifest on sno1
+  kubernetes.core.k8s:
+    kubeconfig: "{{ ansible_facts['user_dir'] }}/kubeconfig-sno1"
+    validate_certs: no
+    src: files/sno1.yml
+
+- name: deploy the manifest on k3s
+  kubernetes.core.k8s:
+    kubeconfig: "{{ ansible_facts['user_dir'] }}/kubeconfig-k3s"
+    validate_certs: no
+    src: files/k3s.yml
+...