Skip to content

Commit 1e78008

Browse files
authored
Fix platform engineering example and kubeconfig retriever (#1452)
* Fix kubeconfigretriever: raw string for jsonpath, handle double-encoded ConfigMap value * Platform engineering example: bitnamilegacy images, steps fixes; fix kubeconfig retriever - steps.txt: add step to copy kubeplus-saas-provider.json into example dir - custom-mysql-1.0-10.1.0.tgz: use bitnamilegacy images so MySQL pods pull - kubeconfigretriever.py: single-quote jsonpath, handle double-encoded ConfigMap, guard dict access * Remove commented-out code in kubeconfigretriever.py * Trigger CI
1 parent 78f205d commit 1e78008

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed
Binary file not shown.

examples/multitenancy/platform-engineering/steps.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Platform Engineering team
3232
$ helm install kubeplus "https://github.com/cloud-ark/operatorcharts/blob/master/kubeplus-chart-4.2.0.tgz?raw=true" --kubeconfig=kubeplus-saas-provider.json
3333
- Wait till KubePlus Pod is Running
3434
$ kubectl get pods -A
35+
- Copy the provider kubeconfig into this directory so the commands below work (run from this directory):
36+
$ cp ../../../kubeplus-saas-provider.json .
3537

3638
4. Create CustomMysqlService API wrapping the Helm chart:
3739
- Check custom-mysql-service-composition-localchart.yaml. Notice that we are specifying our custom mysql chart

plugins/kubeconfigretriever.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,29 @@ def retrieve_kubeconfig(self, serverURL, kubeconfigFor, kubeconfig):
1111

1212
kubeplusNS = self.get_kubeplus_namespace(kubeconfig)
1313
if kubeconfigFor == 'provider':
14-
cmd = "kubectl get configmaps kubeplus-saas-provider -n " + kubeplusNS + " -o jsonpath=\"{.data.kubeplus-saas-provider\.json}\""
14+
cmd = "kubectl get configmaps kubeplus-saas-provider -n " + kubeplusNS + r" -o jsonpath='{.data.kubeplus-saas-provider\.json}'"
1515
if kubeconfigFor == 'consumer':
16-
cmd = "kubectl get configmaps kubeplus-saas-consumer-kubeconfig -n " + kubeplusNS + " -o jsonpath=\"{.data.kubeplus-saas-consumer\.json}\""
16+
cmd = "kubectl get configmaps kubeplus-saas-consumer-kubeconfig -n " + kubeplusNS + r" -o jsonpath='{.data.kubeplus-saas-consumer\.json}'"
1717

18-
#kubeconfigParts = kubeconfig.split("=")
19-
#kubeconfigPath = kubeconfigParts[1].strip()
2018
cmd = cmd + " --kubeconfig=" + kubeconfig
2119
out = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()[0]
22-
#print(out)
2320
out = out.decode('utf-8')
2421
json_output = {}
2522
try:
2623
json_output = json.loads(out)
24+
if isinstance(json_output, str):
25+
json_output = json.loads(json_output)
2726
except Exception as e:
2827
print(e)
2928
print("KubePlus might not be ready yet. Try again once the KubePlus Pod is running.")
30-
if serverURL != '-1':
31-
#parts = serverURL.split("=")
32-
#sURL = parts[1].strip()
33-
#if sURL != '':
34-
json_output["clusters"][0]["cluster"]["server"] = serverURL
35-
try:
36-
pkubeconfig = json.dumps(json_output)
37-
print(pkubeconfig)
38-
except Exception as e:
39-
print(e)
29+
if isinstance(json_output, dict):
30+
if serverURL != '-1':
31+
json_output["clusters"][0]["cluster"]["server"] = serverURL
32+
try:
33+
pkubeconfig = json.dumps(json_output)
34+
print(pkubeconfig)
35+
except Exception as e:
36+
print(e)
4037

4138
if __name__ == '__main__':
4239

0 commit comments

Comments
 (0)