-
Notifications
You must be signed in to change notification settings - Fork 14
/
rhdp.sh
62 lines (45 loc) · 2.26 KB
/
rhdp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
rhdp_get_uuid(){
oc whoami || return 1
UUID=$(oc whoami --show-server | sed 's@https://@@; s@:.*@@; s@api.*-@@; s@[.].*$@@')
export UUID
echo "OCP Cluster UUID: ${UUID}"
}
rhdp_fix_api_certs(){
echo "
issue: RHDP can not start cluster due to ca.crt change
NOTICE: ssh to the RHDP bastion host and run the following commands:
# user: lab-user
sed -i.bak '/certificate-authority-data/d' ~/.kube/config
# user: ec2-user
sudo su ec2-user /bin/bash -c 'id; sed -i.bak '/certificate-authority-data/d' ~/.kube/config'
# user: root
sudo su root /bin/bash -c 'id; sed -i.bak '/certificate-authority-data/d' ~/.kube/config'
"
CERT_NAME=$(oc -n openshift-ingress-operator get ingresscontrollers default --template='{{.spec.defaultCertificate.name}}')
# API_HOST_NAME=$(oc -n openshift-console extract cm/console-config --to=- | sed -n '/masterPublicURL/ s/.*:\/\///; s/:6443//p')
# API_HOST_NAME=$(oc whoami --show-server | sed 's@https://@@; s@:.*@@')
API_HOST_NAME=api.$(oc -n openshift-ingress-operator get dns cluster --template='{{.spec.baseDomain}}')
oc -n openshift-ingress get secret "${CERT_NAME}" -o yaml | \
sed 's/namespace: .*/namespace: openshift-config/' | \
oc -n openshift-config apply -f-
oc patch apiserver cluster --type=merge -p '{"spec":{"servingCerts": {"namedCertificates": [{"names": ["'"${API_HOST_NAME}"'"], "servingCertificate": {"name": "'"${CERT_NAME}"'"}}]}}}'
}
rhdp_aws_stop_all_ec2(){
aws_check_cli || return 0
RUNNING_IDS=$(aws ec2 describe-instances --filters Name=instance-state-name,Values=running --query 'Reservations[].Instances[].InstanceId' --output text | sed 's/\t/ /g')
BASTION_ID=$(aws ec2 describe-instances --filters Name=tag:Name,Values=bastion --query 'Reservations[].Instances[].InstanceId' --output text)
echo "BASTION_ID: ${BASTION_ID}"
aws ec2 stop-instances \
--instance-ids \
"${RUNNING_IDS}" \
--output text >/dev/null
}
rhdp_aws_start_ocp4_cluster(){
aws_check_cli || return 0
CLUSTER_IDS=$(aws ec2 describe-instances --filters Name=tag:env_type,Values=ocp4-cluster --query 'Reservations[].Instances[].InstanceId' --output text | sed 's/\t/ /g')
aws ec2 start-instances \
--instance-ids \
"${CLUSTER_IDS}" \
--output text >/dev/null
}