diff --git a/stepactions/eaas-get-ephemeral-cluster-credentials/0.1/eaas-get-ephemeral-cluster-credentials.yaml b/stepactions/eaas-get-ephemeral-cluster-credentials/0.1/eaas-get-ephemeral-cluster-credentials.yaml index 9d5fac377e..bfb788e965 100644 --- a/stepactions/eaas-get-ephemeral-cluster-credentials/0.1/eaas-get-ephemeral-cluster-credentials.yaml +++ b/stepactions/eaas-get-ephemeral-cluster-credentials/0.1/eaas-get-ephemeral-cluster-credentials.yaml @@ -4,7 +4,7 @@ metadata: name: eaas-get-ephemeral-cluster-credentials spec: description: >- - This StepAction queries the EaaS hub cluster to get the kubeconfig for an ephemeral cluster + This StepAction queries the EaaS hub cluster to get the kubeconfig, username, and password for an ephemeral cluster by name. Credentials are stored in a mounted volume that must be provided as a param. image: registry.redhat.io/openshift4/ose-cli@sha256:15da03b04318bcc842060b71e9dd6d6c2595edb4e8fdd11b0c6781eeb03ca182 params: @@ -26,11 +26,23 @@ spec: results: - name: kubeconfig description: Relative path to the kubeconfig in the mounted volume + - name: username + description: Relative path to the username file in the mounted volume + - name: password + description: Relative path to the password file in the mounted volume + - name: apiServerURL + description: API server URL of the cluster + - name: consoleURL + description: Console URL of the cluster env: - name: CLUSTER_NAME value: "$(params.clusterName)" - name: CLUSTER_KUBECONFIG value: "/credentials/$(params.clusterName)-kubeconfig" + - name: CLUSTER_USERNAME + value: "/credentials/$(params.clusterName)-username" + - name: CLUSTER_PASSWORD + value: "/credentials/$(params.clusterName)-password" - name: KUBECONFIG value: /tmp/eaas-kubeconfig - name: KUBECONFIG_VALUE @@ -56,3 +68,19 @@ spec: "${OC[@]}" get secret $SECRET -o go-template --template="{{.data.kubeconfig|base64decode}}" > $CLUSTER_KUBECONFIG echo "Wrote kubeconfig to $CLUSTER_KUBECONFIG" echo -n $(basename $CLUSTER_KUBECONFIG) > $(step.results.kubeconfig.path) + + # Get username and password + ADMIN_PASSWORD_SECRET=$("${OC[@]}" get cti $CLUSTER_NAME -o=jsonpath='{.status.adminPassword.name}') + echo "Found admin password secret: $ADMIN_PASSWORD_SECRET" + "${OC[@]}" get secret $ADMIN_PASSWORD_SECRET -o jsonpath='{.data.username}' | base64 -d > $CLUSTER_USERNAME + "${OC[@]}" get secret $ADMIN_PASSWORD_SECRET -o jsonpath='{.data.password}' | base64 -d > $CLUSTER_PASSWORD + echo "Wrote username to $CLUSTER_USERNAME" + echo "Wrote password to $CLUSTER_PASSWORD" + echo -n $(basename $CLUSTER_USERNAME) > $(step.results.username.path) + echo -n $(basename $CLUSTER_PASSWORD) > $(step.results.password.path) + + # Get `APIserverURL` and `ConsoleURL` status field values + API_SERVER_URL=$("${OC[@]}" get cti $CLUSTER_NAME -o=jsonpath='{.status.apiServerURL}') + CONSOLE_URL=$("${OC[@]}" get cti $CLUSTER_NAME -o=jsonpath='{.status.consoleURL}') + echo -n "$API_SERVER_URL" > $(step.results.apiServerURL.path) + echo -n "$CONSOLE_URL" > $(step.results.consoleURL.path) \ No newline at end of file