blob: d6e067ea4878c43ebc1a8ecce4bef920ea948225 [file] [log] [blame]
guilhermesteinmuller86a88b62022-05-27 16:45:49 +00001# Copyright (c) 2022 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
Mohammed Naserc8e1a452022-08-11 16:16:13 -040015- name: Deploy service
guilhermesteinmuller86a88b62022-05-27 16:45:49 +000016 kubernetes.core.k8s:
17 state: present
18 definition:
Mohammed Naserc8e1a452022-08-11 16:16:13 -040019 - apiVersion: apps/v1
20 kind: Deployment
21 metadata:
22 name: openstack-exporter
Mohammed Naserb77cea12022-11-28 22:27:10 +000023 namespace: openstack
Mohammed Naserc8e1a452022-08-11 16:16:13 -040024 labels:
guilhermesteinmuller86a88b62022-05-27 16:45:49 +000025 application: openstack-exporter
Mohammed Naserc8e1a452022-08-11 16:16:13 -040026 spec:
27 replicas: 1
28 selector:
29 matchLabels:
guilhermesteinmuller86a88b62022-05-27 16:45:49 +000030 application: openstack-exporter
Mohammed Naserc8e1a452022-08-11 16:16:13 -040031 template:
32 metadata:
33 labels:
34 application: openstack-exporter
35 spec:
36 nodeSelector:
37 openstack-control-plane: enabled
Mohammed Naserb77cea12022-11-28 22:27:10 +000038 initContainers:
39 - name: build-config
Mohammed Naser31171f42023-03-19 00:10:46 +000040 image: "{{ atmosphere_images['bootstrap'] | vexxhost.kubernetes.docker_image('ref') }}"
Mohammed Naserb77cea12022-11-28 22:27:10 +000041 command: ["bash", "-ec"]
42 args:
43 - |
44 cat <<EOF > /etc/openstack/clouds.yaml
45 ---
46 clouds:
47 default:
48 auth:
49 auth_url: "$(OS_AUTH_URL)"
50 project_domain_name: "$(OS_PROJECT_DOMAIN_NAME)"
51 project_name: "$(OS_PROJECT_NAME)"
52 user_domain_name: "$(OS_USER_DOMAIN_NAME)"
53 username: "$(OS_USERNAME)"
54 password: "$(OS_PASSWORD)"
55 region_name: "$(OS_REGION_NAME)"
56 interface: "$(OS_INTERFACE)"
57 identity_api_version: 3
58 identity_interface: "$(OS_INTERFACE)"
59 EOF
60 envFrom:
61 - secretRef:
62 name: keystone-keystone-admin
63 volumeMounts:
64 - name: openstack-config
65 mountPath: /etc/openstack
Mohammed Naserc8e1a452022-08-11 16:16:13 -040066 containers:
67 - name: openstack-exporter
Mohammed Naser31171f42023-03-19 00:10:46 +000068 image: "{{ atmosphere_images['prometheus_openstack_exporter'] | vexxhost.kubernetes.docker_image('ref') }}"
Mohammed Naserc8e1a452022-08-11 16:16:13 -040069 args:
70 - --endpoint-type
71 - internal
72 - default
73 - --collect-metric-time
Rico Lind206f5d2024-04-03 05:11:29 +080074 - -d neutron-l3_agent_of_router
75 - -d loadbalancer-loadbalancer_status
Mohammed Naserc90235e2022-11-29 02:03:52 +000076 ports:
77 - name: metrics
78 containerPort: 9180
Rico Lin17b64112023-08-24 03:13:27 +080079 env:
80 - name: OS_COMPUTE_API_VERSION
81 value: "2.87"
Mohammed Naserc8e1a452022-08-11 16:16:13 -040082 volumeMounts:
83 - name: openstack-config
Mohammed Naserb77cea12022-11-28 22:27:10 +000084 mountPath: /etc/openstack
85 readinessProbe:
86 failureThreshold: 3
87 httpGet:
88 path: /
89 port: 9180
90 scheme: HTTP
91 livenessProbe:
92 failureThreshold: 3
93 httpGet:
94 path: /
95 port: 9180
96 scheme: HTTP
97 periodSeconds: 10
98 successThreshold: 1
99 timeoutSeconds: 1
Mohammed Naserc8e1a452022-08-11 16:16:13 -0400100 volumes:
101 - name: openstack-config
Mohammed Naserb77cea12022-11-28 22:27:10 +0000102 emptyDir: {}
guilhermesteinmuller86a88b62022-05-27 16:45:49 +0000103
Mohammed Naserc8e1a452022-08-11 16:16:13 -0400104 - apiVersion: v1
105 kind: Service
106 metadata:
107 name: openstack-exporter
Mohammed Naserb77cea12022-11-28 22:27:10 +0000108 namespace: openstack
Mohammed Naserc8e1a452022-08-11 16:16:13 -0400109 labels:
110 application: openstack-exporter
111 spec:
112 clusterIP: None
113 ports:
114 - name: metrics
115 port: 9180
116 targetPort: metrics
117 selector:
guilhermesteinmuller86a88b62022-05-27 16:45:49 +0000118 application: openstack-exporter
Rico Lind206f5d2024-04-03 05:11:29 +0800119
Rico Lind206f5d2024-04-03 05:11:29 +0800120- name: Fetch Neutron DB secret
121 run_once: true
122 no_log: true
123 kubernetes.core.k8s_info:
124 kind: Secret
125 namespace: openstack
126 name: neutron-db-user
127 register: _neutron_db_user
128
Mohammed Nasered412102024-04-18 21:26:10 -0400129- name: Fetch Nova DB secret
130 run_once: true
131 no_log: true
132 kubernetes.core.k8s_info:
133 kind: Secret
134 namespace: openstack
135 name: nova-db-user
136 register: _nova_db_user
137
138- name: Fetch Octavia DB secret
139 run_once: true
140 no_log: true
141 kubernetes.core.k8s_info:
142 kind: Secret
143 namespace: openstack
144 name: octavia-db-user
145 register: _octavia_db_user
146
Rico Lind206f5d2024-04-03 05:11:29 +0800147- name: Create "openstack-database-exporter-dsn" secret
148 run_once: true
149 no_log: true
150 kubernetes.core.k8s:
151 state: present
152 definition:
153 apiVersion: v1
154 kind: Secret
155 type: Opaque
156 metadata:
157 name: openstack-database-exporter-dsn
158 namespace: openstack
159 labels:
160 application: openstack-database-exporter
161 stringData:
Mohammed Naser08ff8812024-06-21 10:56:32 -0400162 NEUTRON_DSN: "{{ _neutron_db_user.resources.0.data.DB_CONNECTION | b64decode | regex_replace('^.*//', '') | regex_replace('@(.*)/', '@tcp(\\1)/') }}"
163 NOVA_DSN: "{{ _nova_db_user.resources.0.data.DB_CONNECTION | b64decode | regex_replace('^.*//', '') | regex_replace('@(.*)/', '@tcp(\\1)/') }}"
164 NOVA_API_DSN: "{{ _nova_db_user.resources.0.data.DB_CONNECTION | b64decode | regex_replace('^.*//', '') | regex_replace('@(.*)/', '@tcp(\\1)/') }}_api"
165 OCTAVIA_DSN: "{{ _octavia_db_user.resources.0.data.DB_CONNECTION | b64decode | regex_replace('^.*//', '') | regex_replace('@(.*)/', '@tcp(\\1)/') }}"
Rico Lind206f5d2024-04-03 05:11:29 +0800166
167- name: Deploy service
168 run_once: true
169 kubernetes.core.k8s:
170 state: present
171 definition:
172 - apiVersion: apps/v1
173 kind: Deployment
174 metadata:
175 name: openstack-database-exporter
176 namespace: openstack
177 labels:
178 application: openstack-database-exporter
179 spec:
180 replicas: 1
181 selector:
182 matchLabels:
183 application: openstack-database-exporter
184 template:
185 metadata:
186 labels:
187 application: openstack-database-exporter
188 spec:
189 nodeSelector:
190 openstack-control-plane: enabled
191 containers:
192 - name: openstack-database-exporter
193 image: "{{ atmosphere_images['prometheus_openstack_database_exporter'] | vexxhost.kubernetes.docker_image('ref') }}"
194 envFrom:
195 - secretRef:
196 name: openstack-database-exporter-dsn
197 ports:
198 - name: metrics
199 containerPort: 9180
200 readinessProbe:
201 failureThreshold: 3
202 httpGet:
203 path: /
204 port: 9180
205 scheme: HTTP
206 livenessProbe:
207 failureThreshold: 3
208 httpGet:
209 path: /
210 port: 9180
211 scheme: HTTP
212 periodSeconds: 10
213 successThreshold: 1
214 timeoutSeconds: 1