blob: d0bd92d271cf30db60d562f092d9c15633c2a070 [file] [log] [blame]
Mohammed Naserbdb97742022-09-26 15:20:49 -04001from taskflow import engines
Mohammed Naser313085b2022-09-19 21:46:16 -04002from taskflow.patterns import graph_flow
Mohammed Naser124a9bc2022-09-19 15:13:16 -04003
4from atmosphere.config import CONF
Mohammed Naserbdb97742022-09-26 15:20:49 -04005from atmosphere.tasks import constants
Mohammed Naser22228542022-09-26 14:23:29 -04006from atmosphere.tasks.composite import openstack_helm
7from atmosphere.tasks.kubernetes import flux, v1
Mohammed Naser124a9bc2022-09-19 15:13:16 -04008
Mohammed Naser55d348d2022-09-20 00:25:09 -04009
Mohammed Naserbdb97742022-09-26 15:20:49 -040010def get_engine():
11 return engines.load(
12 get_deployment_flow(),
13 executor="greenthreaded",
14 engine="parallel",
15 max_workers=4,
16 )
Mohammed Naser22228542022-09-26 14:23:29 -040017
Mohammed Naser124a9bc2022-09-19 15:13:16 -040018
Mohammed Naser55d348d2022-09-20 00:25:09 -040019def get_deployment_flow():
Mohammed Naser64da5c62022-09-20 17:33:34 -040020 flow = graph_flow.Flow("deploy").add(
21 # kube-system
Mohammed Naserbdb97742022-09-26 15:20:49 -040022 v1.ApplyNamespaceTask(name=constants.NAMESPACE_KUBE_SYSTEM),
Mohammed Naser22228542022-09-26 14:23:29 -040023 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040024 namespace=constants.NAMESPACE_KUBE_SYSTEM,
25 name=constants.HELM_REPOSITORY_CEPH,
Mohammed Naser64da5c62022-09-20 17:33:34 -040026 url="https://ceph.github.io/csi-charts",
27 ),
28 # cert-manager
Mohammed Naserbdb97742022-09-26 15:20:49 -040029 v1.ApplyNamespaceTask(name=constants.NAMESPACE_CERT_MANAGER),
Mohammed Naser22228542022-09-26 14:23:29 -040030 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040031 namespace=constants.NAMESPACE_CERT_MANAGER,
32 name=constants.HELM_REPOSITORY_JETSTACK,
Mohammed Naser64da5c62022-09-20 17:33:34 -040033 url="https://charts.jetstack.io",
34 ),
Mohammed Nasere1e1ae42022-09-26 20:03:27 -040035 flux.ApplyHelmReleaseTask(
36 namespace=constants.NAMESPACE_CERT_MANAGER,
37 name=constants.HELM_RELEASE_CERT_MANAGER_NAME,
38 repository=constants.HELM_REPOSITORY_JETSTACK,
39 chart=constants.HELM_RELEASE_CERT_MANAGER_NAME,
40 version=constants.HELM_RELEASE_CERT_MANAGER_VERSION,
41 values=constants.HELM_RELEASE_CERT_MANAGER_VALUES,
42 ),
Mohammed Naser64da5c62022-09-20 17:33:34 -040043 # monitoring
Mohammed Naserbdb97742022-09-26 15:20:49 -040044 v1.ApplyNamespaceTask(name=constants.NAMESPACE_MONITORING),
Mohammed Naser22228542022-09-26 14:23:29 -040045 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040046 namespace=constants.NAMESPACE_MONITORING,
47 name=constants.HELM_REPOSITORY_PROMETHEUS_COMMUINTY,
Mohammed Naser64da5c62022-09-20 17:33:34 -040048 url="https://prometheus-community.github.io/helm-charts",
49 ),
Mohammed Naser22228542022-09-26 14:23:29 -040050 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040051 namespace=constants.NAMESPACE_MONITORING,
52 name=constants.HELM_REPOSITORY_NODE_FEATURE_DISCOVERY,
Mohammed Naser64da5c62022-09-20 17:33:34 -040053 url="https://kubernetes-sigs.github.io/node-feature-discovery/charts",
54 ),
Mohammed Naser22228542022-09-26 14:23:29 -040055 flux.ApplyHelmReleaseTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040056 namespace=constants.NAMESPACE_MONITORING,
Mohammed Naser52f3feb2022-09-21 13:49:15 -040057 name="node-feature-discovery",
Mohammed Naserbdb97742022-09-26 15:20:49 -040058 repository=constants.HELM_REPOSITORY_NODE_FEATURE_DISCOVERY,
Mohammed Naser52f3feb2022-09-21 13:49:15 -040059 chart="node-feature-discovery",
60 version="0.11.2",
Mohammed Naserbdb97742022-09-26 15:20:49 -040061 values=constants.HELM_RELEASE_NODE_FEATURE_DISCOVERY_VALUES,
Mohammed Naser52f3feb2022-09-21 13:49:15 -040062 ),
Mohammed Naser64da5c62022-09-20 17:33:34 -040063 # openstack
Mohammed Naserbdb97742022-09-26 15:20:49 -040064 v1.ApplyNamespaceTask(name=constants.NAMESPACE_OPENSTACK),
Mohammed Naser22228542022-09-26 14:23:29 -040065 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040066 namespace=constants.NAMESPACE_OPENSTACK,
67 name=constants.HELM_REPOSITORY_BITNAMI,
Mohammed Naser64da5c62022-09-20 17:33:34 -040068 url="https://charts.bitnami.com/bitnami",
69 ),
Mohammed Nasere1e1ae42022-09-26 20:03:27 -040070 flux.ApplyHelmReleaseTask(
71 namespace=constants.NAMESPACE_OPENSTACK,
72 name=constants.HELM_RELEASE_RABBITMQ_OPERATOR_NAME,
73 repository=constants.HELM_REPOSITORY_BITNAMI,
74 chart=constants.HELM_RELEASE_RABBITMQ_OPERATOR_NAME,
75 version=constants.HELM_RELEASE_RABBITMQ_OPERATOR_VERSION,
76 values=constants.HELM_RELEASE_RABBITMQ_OPERATOR_VALUES,
77 requires=constants.HELM_RELEASE_RABBITMQ_OPERATOR_REQUIRES,
78 ),
Mohammed Naser22228542022-09-26 14:23:29 -040079 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040080 namespace=constants.NAMESPACE_OPENSTACK,
81 name=constants.HELM_REPOSITORY_PERCONA,
Mohammed Naser64da5c62022-09-20 17:33:34 -040082 url="https://percona.github.io/percona-helm-charts/",
83 ),
Mohammed Naser22228542022-09-26 14:23:29 -040084 flux.ApplyHelmReleaseTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040085 namespace=constants.NAMESPACE_OPENSTACK,
86 name=constants.HELM_RELEASE_PXC_OPERATOR_NAME,
87 repository=constants.HELM_REPOSITORY_PERCONA,
88 chart=constants.HELM_RELEASE_PXC_OPERATOR_NAME,
89 version=constants.HELM_RELEASE_PXC_OPERATOR_VERSION,
90 values=constants.HELM_RELEASE_PXC_OPERATOR_VALUES,
91 ),
92 openstack_helm.ApplyPerconaXtraDBClusterTask(
93 namespace=constants.NAMESPACE_OPENSTACK,
Mohammed Naser22228542022-09-26 14:23:29 -040094 ),
95 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -040096 namespace=constants.NAMESPACE_OPENSTACK,
97 name=constants.HELM_REPOSITORY_INGRESS_NGINX,
Mohammed Naser64da5c62022-09-20 17:33:34 -040098 url="https://kubernetes.github.io/ingress-nginx",
99 ),
Mohammed Naser22228542022-09-26 14:23:29 -0400100 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -0400101 namespace=constants.NAMESPACE_OPENSTACK,
102 name=constants.HELM_REPOSITORY_OPENSTACK_HELM_INFRA,
Mohammed Naser64da5c62022-09-20 17:33:34 -0400103 url="https://tarballs.opendev.org/openstack/openstack-helm-infra/",
104 ),
Mohammed Naser22228542022-09-26 14:23:29 -0400105 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -0400106 namespace=constants.NAMESPACE_OPENSTACK,
107 name=constants.HELM_REPOSITORY_COREDNS,
Mohammed Naser64da5c62022-09-20 17:33:34 -0400108 url="https://coredns.github.io/helm",
109 ),
Mohammed Naser22228542022-09-26 14:23:29 -0400110 flux.ApplyHelmRepositoryTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -0400111 namespace=constants.NAMESPACE_OPENSTACK,
112 name=constants.HELM_REPOSITORY_OPENSTACK_HELM,
Mohammed Naser64da5c62022-09-20 17:33:34 -0400113 url="https://tarballs.opendev.org/openstack/openstack-helm/",
114 ),
115 )
Mohammed Naser55d348d2022-09-20 00:25:09 -0400116
Mohammed Naser64da5c62022-09-20 17:33:34 -0400117 if CONF.memcached.enabled:
118 flow.add(
Mohammed Naser22228542022-09-26 14:23:29 -0400119 openstack_helm.ApplyReleaseSecretTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -0400120 namespace=constants.NAMESPACE_OPENSTACK, chart="memcached"
Mohammed Naser64da5c62022-09-20 17:33:34 -0400121 ),
Mohammed Naser22228542022-09-26 14:23:29 -0400122 openstack_helm.ApplyHelmReleaseTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -0400123 namespace=constants.NAMESPACE_OPENSTACK,
124 repository=constants.HELM_REPOSITORY_OPENSTACK_HELM_INFRA,
Mohammed Nasere48a6772022-09-23 12:01:21 -0400125 name="memcached",
126 version="0.1.12",
127 ),
Mohammed Naser22228542022-09-26 14:23:29 -0400128 v1.ApplyServiceTask(
Mohammed Naserbdb97742022-09-26 15:20:49 -0400129 namespace=constants.NAMESPACE_OPENSTACK,
Mohammed Nasere48a6772022-09-23 12:01:21 -0400130 name="memcached-metrics",
131 labels={
132 "application": "memcached",
133 "component": "server",
134 },
135 spec={
136 "selector": {
137 "application": "memcached",
138 "component": "server",
139 },
140 "ports": [
141 {
142 "name": "metrics",
143 "port": 9150,
144 "targetPort": 9150,
145 }
146 ],
147 },
148 ),
Mohammed Naser64da5c62022-09-20 17:33:34 -0400149 )
Mohammed Naser55d348d2022-09-20 00:25:09 -0400150
151 return flow