@@ -64,38 +64,106 @@ echo "# Generating ~/tmp/clouds-$OS_CLOUD.yaml ..."
6464OLD_UMASK=$( umask)
6565umask 0177
6666INJECTSUB=" $SECRETS " INJECTSUBKWD=" auth" RMVCOMMENT=1 extract_yaml clouds.$OS_CLOUD < $CLOUDS_YAML | sed " s/^\\ (\\ s*\\ )\\ ($OS_CLOUD \\ ):/\\ 1openstack:/" > ~ /tmp/clouds-$OS_CLOUD .yaml
67- sed -i ' s@^\(\s*cacert:\).*@\1 /etc/openstack/cacert.pem@' ~ /tmp/clouds-$OS_CLOUD .yaml
67+ sed -i ' s@^\(\s*cacert:\).*@\1 /etc/certs/cacert@' ~ /tmp/clouds-$OS_CLOUD .yaml
68+ # echo "octavia_ovn: true" >> ~/tmp/clouds-$OS_CLOUD.yaml
6869CL_YAML=$( ls ~ /tmp/clouds-$OS_CLOUD .yaml)
6970CL_YAML_B64=$( base64 -w0 < " $CL_YAML " )
71+ CL_NAME_B64=$( echo -n openstack | base64 -w0)
7072# kubectl create secret -n $CS_NAMESPACE generic clouds-yaml --from-file=$CL_YAML
73+
7174umask $OLD_UMASK
7275if test -n " $OS_CACERT " ; then
7376 OS_CACERT=${OS_CACERT/ \~ / $HOME }
7477 CACERT_B64=$( base64 -w0 < $OS_CACERT )
75- cat | kubectl apply -f - << EOT
78+ # For OCCM and CSI, the location of cacert is /etc/config
79+ CL_YAML_ALT_B64=$( base64 -w0 < <( sed ' s@/etc/certs/cacert@/etc/openstacǩ/cacert@' " $CL_YAML " ) )
80+ CLCONF_B64=$( base64 -w0 << EOT
81+ apiVersion: v1
82+ kind: Secret
83+ type: Opaque
84+ metadata:
85+ name: clouds-yaml
86+ namespace: kube-system
87+ data:
88+ clouds.yaml: $CL_YAML_ALT_B64
89+ cacert: $CACERT_B64
90+ cloudName: $CL_NAME_B64
91+ EOT
92+ )
93+ # For CAPO
94+ kubectl apply -f - << EOT
7695apiVersion: v1
7796data:
7897 clouds.yaml: $CL_YAML_B64
79- cacert.pem: $CACERT_B64
98+ cacert: $CACERT_B64
99+ cloudName: $CL_NAME_B64
80100kind: Secret
81101metadata:
82102 name: openstack
83- namespace: $CS_NAMESPACCE
103+ namespace: $CS_NAMESPACE
104+ labels:
105+ clusterctl.cluster.x-k8s.io/move: "true"
84106type: Opaque
85107EOT
86108else
87- cat | kubectl apply -f << EOT
109+ CLCONF_B64=$( base64 -w0 << EOT
110+ apiVersion: v1
111+ kind: Secret
112+ type: Opaque
113+ metadata:
114+ name: clouds-yaml
115+ namespace: kube-system
116+ data:
117+ clouds.yaml: $CL_YAML_B64
118+ cloudName: $CL_NAME_B64
119+ EOT
120+ )
121+ # For CAPO
122+ kubectl apply -f - << EOT
88123apiVersion: v1
89124data:
90125 clouds.yaml: $CL_YAML_B64
126+ cloudName: $CL_NAME_B64
91127kind: Secret
92128metadata:
93129 name: openstack
94- namespace: $CS_NAMESPACCE
130+ namespace: $CS_NAMESPACE
131+ labels:
132+ clusterctl.cluster.x-k8s.io/move: "true"
95133type: Opaque
96134EOT
97135fi
98136# FIXME: We will provide more settings in cluster-settings.env later, hardcode it for now
99137# if test "$CS_CCMLB=octavia-ovn"; then OCTOVN="--set octavia_ovn=true"; else unset OCTOVN; fi
100138# FIXME: How to pass the information that we want OVN loadbalancers???
101-
139+ # Workload cluster secret (for OCCM, CSI)
140+ kubectl apply -f - << EOT
141+ apiVersion: v1
142+ data:
143+ clouds-yaml-secret: $CLCONF_B64
144+ kind: Secret
145+ metadata:
146+ name: openstack-workload-cluster-secret
147+ namespace: $CS_NAMESPACE
148+ labels:
149+ clusterctl.cluster.x-k8s.io/move: "true"
150+ type: addons.cluster.x-k8s.io/resource-set
151+ EOT
152+ # Create CRS
153+ kubectl apply -f - << EOT
154+ apiVersion: addons.cluster.x-k8s.io/v1beta1
155+ kind: ClusterResourceSet
156+ metadata:
157+ name: crs-openstack-secret
158+ namespace: $CS_NAMESPACE
159+ labels:
160+ clusterctl.cluster.x-k8s.io/move: "true"
161+ spec:
162+ strategy: "Reconcile"
163+ clusterSelector:
164+ matchLabels:
165+ managed-secret: clouds-yaml
166+ resources:
167+ - name: openstack-workload-cluster-secret
168+ kind: Secret
169+ EOT
0 commit comments