Skip to content

Commit 32dc3c6

Browse files
RaniprathyushaRaniprathyusha-Elaprolu
andauthored
Enable SSL verification (#2613)
Co-authored-by: Raniprathyusha-Elaprolu <[email protected]>
1 parent 4557ebc commit 32dc3c6

File tree

1 file changed

+60
-41
lines changed

1 file changed

+60
-41
lines changed

cs-onprem-tenant-config.sh

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ checkIfhostReachable() {
5757
if [ -n "$custom_hostname" ]; then
5858
echo "Given Custom Hostname: $custom_hostname"
5959
if host "$custom_hostname" >/dev/null 2>&1; then
60-
echo "Host is reachable. Proceeding further..."
60+
echo "Domain is defined. Proceeding further..."
6161
else
62-
echo "$custom_hostname is not reachable. Exiting the script."
62+
echo "$custom_hostname is not defined. Exiting the script."
6363
exit 1
6464
fi
6565
fi
@@ -87,7 +87,16 @@ checkIfSecretExist
8787

8888
# delete completed job if exists
8989
echo "Deleting old job of iam-custom-hostname if exists"
90-
oc delete job iam-custom-hostname --ignore-not-found -n $csNamespace
90+
oc delete job iam-custom-hostname --ignore-not-found -n $map_to_common_service_namespace
91+
92+
operator_token=$(oc create token ibm-iam-operator -n $csNamespace)
93+
if [[ -z "${operator_token}" ]]
94+
then
95+
>&2 echo "Failed to set a ServiceAccount token; exit"
96+
return 1
97+
fi
98+
99+
oc project $map_to_common_service_namespace
91100

92101
echo "Running custom hostname job"
93102
tmpfile=$(mktemp)
@@ -96,7 +105,7 @@ apiVersion: batch/v1
96105
kind: Job
97106
metadata:
98107
name: iam-custom-hostname
99-
namespace: $csNamespace
108+
namespace: $map_to_common_service_namespace
100109
labels:
101110
app: iam-custom-hostname
102111
spec:
@@ -106,30 +115,42 @@ spec:
106115
app: iam-custom-hostname
107116
spec:
108117
containers:
109-
- name: iam-custom-hostname
110-
image: icr.io/cpopen/cpfs/iam-custom-hostname:latest
111-
command: ["python3", "/scripts/saas_script.py"]
112-
imagePullPolicy: Always
113-
env:
114-
- name: OPENSHIFT_URL
115-
value: https://kubernetes.default:443
116-
- name: IDENTITY_PROVIDER_URL
117-
value: https://platform-identity-provider.$map_to_common_service_namespace.svc:4300
118-
- name: PLATFORM_AUTH_URL
119-
value: https://platform-auth-service.$map_to_common_service_namespace.svc:9443
120-
- name: POD_NAMESPACE
121-
value: $map_to_common_service_namespace
122-
- name: WLP_CLIENT_ID
123-
value: $wlp_client_id
124-
- name: WLP_CLIENT_SECRET
125-
value: $wlp_client_secret
126-
- name: OAUTH2_CLIENT_REGISTRATION_SECRET
127-
value: $oauth2_client_registration_secret
128-
- name: DEFAULT_ADMIN_USER
129-
value: $admin_username
130-
- name: DEFAULT_ADMIN_PASSWORD
131-
value: $admin_password
132-
serviceAccountName: ibm-iam-operator
118+
- name: iam-custom-hostname
119+
image: icr.io/cpopen/cpfs/iam-custom-hostname:latest
120+
command: ["python3", "/scripts/saas_script.py"]
121+
imagePullPolicy: Always
122+
env:
123+
- name: OPERATOR_TOKEN
124+
value: $operator_token
125+
- name: OPENSHIFT_URL
126+
value: https://kubernetes.default:443
127+
- name: IDENTITY_PROVIDER_URL
128+
value: https://platform-identity-provider.$map_to_common_service_namespace.svc:4300
129+
- name: PLATFORM_AUTH_URL
130+
value: https://platform-auth-service:9443
131+
- name: POD_NAMESPACE
132+
value: $map_to_common_service_namespace
133+
- name: WLP_CLIENT_ID
134+
value: $wlp_client_id
135+
- name: WLP_CLIENT_SECRET
136+
value: $wlp_client_secret
137+
- name: OAUTH2_CLIENT_REGISTRATION_SECRET
138+
value: $oauth2_client_registration_secret
139+
- name: DEFAULT_ADMIN_USER
140+
value: $admin_username
141+
- name: DEFAULT_ADMIN_PASSWORD
142+
value: $admin_password
143+
volumeMounts:
144+
- name: provider-ca-volume
145+
mountPath: /custom-certs
146+
readOnly: true
147+
volumes:
148+
- name: provider-ca-volume
149+
secret:
150+
secretName: identity-provider-secret
151+
items:
152+
- key: ca.crt
153+
path: ca.crt
133154
restartPolicy: OnFailure
134155
EOF
135156
oc apply -f "$tmpfile"
@@ -143,6 +164,12 @@ check_job_completion() {
143164
# Call the function to check job completion
144165
check_job_completion iam-custom-hostname $csNamespace
145166

167+
#sleep for 10s and compare existing custom_hostname with the current route
168+
sleep 15
169+
170+
oc delete pod -l app=platform-auth-service -n $map_to_common_service_namespace
171+
echo "Triggered restart of platform-auth-service pods"
172+
146173
deployment_name="platform-auth-service"
147174
timeout_seconds=180 # assuming auth-service will come in 3 mins after restart
148175

@@ -151,13 +178,9 @@ end_time=$((start_time + timeout_seconds))
151178

152179
while true; do
153180
status=$(oc get deployment "$deployment_name" -n $map_to_common_service_namespace -o jsonpath='{.status.conditions[?(@.type=="Available")].status}')
154-
155-
echo "Triggered restart of platform-auth-service pod"
156-
oc delete pod -l app=platform-auth-service -n "$map_to_common_service_namespace"
157-
pod_phase=$(oc get pod -l app=platform-auth-service -n "$map_to_common_service_namespace" -o jsonpath='{.items[0].status.phase}' 2>/dev/null)
158181

159-
if [[ "$status" == "True" && "$pod_phase" == "Running" ]]; then
160-
echo "$deployment_name deployment is available and pod is running"
182+
if [[ "$status" == "True" ]]; then
183+
echo "$deployment_name is available."
161184
break
162185
fi
163186

@@ -170,11 +193,8 @@ while true; do
170193
sleep 5 # Wait for 5 seconds before checking again
171194
done
172195

173-
#sleep for 10s and compare existing custom_hostname with the current route
174-
sleep 15
175-
176-
username=$(oc get secret platform-auth-idp-credentials -n ibm-common-services -o json | jq -r .data.admin_username| base64 -d)
177-
password=$(oc get secret platform-auth-idp-credentials -n ibm-common-services -o json | jq -r .data.admin_password | base64 -d)
196+
username=$(oc get secret platform-auth-idp-credentials -n $map_to_common_service_namespace -o json | jq -r .data.admin_username| base64 -d)
197+
password=$(oc get secret platform-auth-idp-credentials -n $map_to_common_service_namespace -o json | jq -r .data.admin_password | base64 -d)
178198
route=$(oc get routes cp-console -o jsonpath='{.spec.host}')
179199

180200

@@ -190,9 +210,8 @@ else
190210
fi
191211

192212
new_hostname=$(oc get routes cp-console --no-headers | awk '{print $2}')
193-
194213
if [ "$new_hostname" = "$custom_hostname" ]; then
195214
echo "successfully updated the custom hostname"
196215
else
197216
echo "update custom hostname failed "
198-
fi
217+
fi

0 commit comments

Comments
 (0)