Skip to content

Commit f315c37

Browse files
committed
Alternative cloud configuration.
This requires SovereignCloudStack/cluster-stacks#225 to land. With it, we don't create cloud.conf using the openstack-csp-helper helm charts, but create a clouds.yaml file that capo understands anyway and that OCCM can process with the right settings (use-clouds = true and create: true). Does not work yet. * Somehow the secret is not transferred to the workload cluster, despite our clusterresourceset magic * If we transfer it, OCCM still does not seem to process it. Signed-off-by: Kurt Garloff <kurt@garloff.de>
1 parent b7a2c56 commit f315c37

File tree

1 file changed

+75
-7
lines changed

1 file changed

+75
-7
lines changed

_04-clouds-yaml.sh

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,38 +64,106 @@ echo "# Generating ~/tmp/clouds-$OS_CLOUD.yaml ..."
6464
OLD_UMASK=$(umask)
6565
umask 0177
6666
INJECTSUB="$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
6869
CL_YAML=$(ls ~/tmp/clouds-$OS_CLOUD.yaml)
6970
CL_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+
7174
umask $OLD_UMASK
7275
if 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
7695
apiVersion: v1
7796
data:
7897
clouds.yaml: $CL_YAML_B64
79-
cacert.pem: $CACERT_B64
98+
cacert: $CACERT_B64
99+
cloudName: $CL_NAME_B64
80100
kind: Secret
81101
metadata:
82102
name: openstack
83-
namespace: $CS_NAMESPACCE
103+
namespace: $CS_NAMESPACE
104+
labels:
105+
clusterctl.cluster.x-k8s.io/move: "true"
84106
type: Opaque
85107
EOT
86108
else
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
88123
apiVersion: v1
89124
data:
90125
clouds.yaml: $CL_YAML_B64
126+
cloudName: $CL_NAME_B64
91127
kind: Secret
92128
metadata:
93129
name: openstack
94-
namespace: $CS_NAMESPACCE
130+
namespace: $CS_NAMESPACE
131+
labels:
132+
clusterctl.cluster.x-k8s.io/move: "true"
95133
type: Opaque
96134
EOT
97135
fi
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

Comments
 (0)