Ilya Kharin | fd293c4 | 2017-03-14 17:34:12 +0400 | [diff] [blame] | 1 | {%- from "devops_portal/map.jinja" import config with context %} |
Ilya Kharin | a7167fb | 2017-03-16 15:30:14 +0400 | [diff] [blame] | 2 | {%- from "devops_portal/map.jinja" import setup with context %} |
| 3 | {%- if setup.engine == "kubernetes" %} |
| 4 | {%- set namespace = setup.kubernetes.namespace|default("oss") %} |
Ilya Kharin | 6e04186 | 2017-03-06 15:32:28 +0400 | [diff] [blame] | 5 | |
| 6 | devops_portal_kubernetes_dir: |
| 7 | file.directory: |
Ilya Kharin | fd293c4 | 2017-03-14 17:34:12 +0400 | [diff] [blame] | 8 | - name: {{ config.base_dir }}/kubernetes |
Ilya Kharin | 6e04186 | 2017-03-06 15:32:28 +0400 | [diff] [blame] | 9 | - user: root |
| 10 | - group: root |
| 11 | - mode: 0755 |
| 12 | - makedirs: true |
| 13 | |
| 14 | devops_portal_k8s_svc: |
| 15 | file.managed: |
Ilya Kharin | fd293c4 | 2017-03-14 17:34:12 +0400 | [diff] [blame] | 16 | - name: {{ config.base_dir }}/kubernetes/devops_portal-svc.yaml |
Ilya Kharin | 6e04186 | 2017-03-06 15:32:28 +0400 | [diff] [blame] | 17 | - source: salt://devops_portal/files/kubernetes/devops_portal-svc.yaml |
| 18 | - template: jinja |
| 19 | - require: |
| 20 | - file: devops_portal_kubernetes_dir |
| 21 | |
| 22 | devops_portal_k8s_cm: |
| 23 | file.managed: |
Ilya Kharin | fd293c4 | 2017-03-14 17:34:12 +0400 | [diff] [blame] | 24 | - name: {{ config.base_dir }}/kubernetes/devops_portal-cm.yaml |
Ilya Kharin | 6e04186 | 2017-03-06 15:32:28 +0400 | [diff] [blame] | 25 | - source: salt://devops_portal/files/kubernetes/devops_portal-cm.yaml |
| 26 | - template: jinja |
| 27 | - require: |
| 28 | - file: devops_portal_kubernetes_dir |
| 29 | - file: devops_portal_nginx_conf |
| 30 | - file: devops_portal_config |
| 31 | |
| 32 | devops_portal_k8s_deploy: |
| 33 | file.managed: |
Ilya Kharin | fd293c4 | 2017-03-14 17:34:12 +0400 | [diff] [blame] | 34 | - name: {{ config.base_dir }}/kubernetes/devops_portal-deploy.yaml |
Ilya Kharin | 6e04186 | 2017-03-06 15:32:28 +0400 | [diff] [blame] | 35 | - source: salt://devops_portal/files/kubernetes/devops_portal-deploy.yaml |
| 36 | - template: jinja |
| 37 | - require: |
| 38 | - file: devops_portal_kubernetes_dir |
| 39 | - file: devops_portal_k8s_cm |
| 40 | |
| 41 | devop_portal_namespace: |
| 42 | cmd.run: |
| 43 | - name: hyperkube kubectl create namespace {{ namespace }} |
| 44 | - unless: hyperkube kubectl get namespaces {{ namespace }} |
| 45 | |
| 46 | apply_devops_portal: |
| 47 | cmd.run: |
| 48 | - name: hyperkube kubectl apply |
Ilya Kharin | fd293c4 | 2017-03-14 17:34:12 +0400 | [diff] [blame] | 49 | --filename {{ config.base_dir }}/kubernetes/devops_portal-svc.yaml |
| 50 | --filename {{ config.base_dir }}/kubernetes/devops_portal-cm.yaml |
| 51 | --filename {{ config.base_dir }}/kubernetes/devops_portal-deploy.yaml |
Ilya Kharin | 6e04186 | 2017-03-06 15:32:28 +0400 | [diff] [blame] | 52 | --namespace={{ namespace }} |
| 53 | --record |
| 54 | - require: |
| 55 | - cmd: devop_portal_namespace |
| 56 | - file: devops_portal_k8s_svc |
| 57 | - file: devops_portal_k8s_cm |
| 58 | - file: devops_portal_k8s_deploy |
| 59 | |
| 60 | {%- endif %} |