-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdemo
executable file
·135 lines (105 loc) · 5.32 KB
/
demo
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
DEMO_DIR="$( dirname "${BASH_SOURCE[0]}" )"
ROOT_DIR="$( cd ${DEMO_DIR}/.. && pwd)"
. demo-magic
TYPE_SPEED=30
# PROMPT_AFTER=1
DEMO_PROMPT="☸️ $ "
NO_WAIT=1
# function () {
# if [[ -n "${NO_WAIT}" ]]; then
# sleep 2
# else
# if [[ -n "${1-}" ]]; then
# sleep "$1"
# else
#
# fi
# fi
# }
function comment() {
echo -e '\033[0;33m>>> '$1' <<<\033[0m'
wait
}
comment "Instruction for obtaining credential for registry.ci.openshift.org"
echo "1. login to https://console-openshift-console.apps.ci.l2s4.p1.openshiftapps.com/ with your github id (you must be in openshift org)"
echo "2. copy the oc login command and run it"
echo "3. run 'oc registry login --to=-' to print out the pull secret"
echo "4. append the pull secret to your openshift pull secret (so that it will be inserted in your openshift global pull secret)"
echo "NOTE: the credential does expire"
comment "cloneing hypershift repo"
pe "git clone https://github.com/openshift/hypershift.git"
comment "host cluster info"
pe "oc config view --minify=true --raw=true > hub.kubeconfig"
pe "export KUBECONFIG=$PWD/hub.kubeconfig"
pe "oc cluster-info"
comment "build and install hypershift"
pe "pushd hypershift"
pe "make build"
pe "./bin/hypershift install"
pe "popd"
comment "create the hypershift-clusters namespace"
pe "oc create namespace hypershift-clusters"
comment "copy ocp global pull secret to hypershift-clusters namespace"
pull_secret=$(mktemp /tmp/pull-secret.XXXXXX)
pe "oc get secret -n openshift-config pull-secret -o jsonpath={.data.\\\.dockerconfigjson} | base64 -d > $pull_secret"
pe "oc create secret docker-registry -n hypershift-clusters pull-secret --from-file=.dockerconfigjson=$pull_secret"
rm -rf $pull_secret
comment "create hyper-acm-1 HostedCluster"
cat host/hypershift/hypershift-controlplane.yaml
pe "oc apply -f host/hypershift/hypershift-controlplane.yaml"
comment "hypershift operator will create a namespace for the hypershift hosted cluster"
pe "oc get ns | grep hypershift-clusters-acm-1"
comment "TODO: wait for hypershift guest cluster to be available"
comment "get kubeconfig for the hosted cluster"
pe "kubeconfig_name=`oc get hostedcluster -n hypershift-clusters acm-1 -o jsonpath={.status.kubeconfig.name}`"
pe "oc get secret -n hypershift-clusters $kubeconfig_name -o jsonpath={.data.kubeconfig} | base64 -d > $kubeconfig_name.kubeconfig"
comment "add ACM CRD to hosted cluster"
pe "export KUBECONFIG=$kubeconfig_name.kubeconfig"
pe "oc apply -f guest/crds"
comment "deploying ACM hub component on the hypershift host in hosted cluster namespace"
pe "export KUBECONFIG=hub.kubeconfig"
pe "oc apply -f host/registration -n hypershift-clusters-acm-1"
pe "oc apply -f host/managedcluster-import-controller -n hypershift-clusters-acm-1"
comment "[HACK] the managedcluster-import-controller code has been modified to disable leader election"
echo "for more information https://github.com/TheRealHaoLiu/managedcluster-import-controller/commit/b7d9f54b99c242caeb1393cee6c315a031a9e2c8"
comment "[HACK] create namespace on guest cluster to support leader election of registration controller"
pe "export KUBECONFIG=$kubeconfig_name.kubeconfig"
pe "oc create namespace hypershift-clusters-acm-1"
comment "[HACK] copy ocp global pull secret to hypershift-clusters-acm-1 namespace"
pe "export KUBECONFIG=$kubeconfig_name.kubeconfig"
pull_secret=$(mktemp /tmp/pull-secret.XXXXXX)
pe "oc get secret -n openshift-config pull-secret -o jsonpath={.data.\\\.dockerconfigjson} | base64 -d > $pull_secret"
pe "oc create secret docker-registry -n hypershift-clusters-acm-1 pull-secret --from-file=.dockerconfigjson=$pull_secret"
rm -rf $pull_secret
comment "TODO: Wait for ACM hub components to be deployed"
comment "start KinD cluster"
pe "export KUBECONFIG=managed-cluster.kubeconfig"
pe "kind create cluster --name=managed-cluster"
comment "create managedcluster on hosted cluster"
pe "export KUBECONFIG=$kubeconfig_name.kubeconfig"
pe "oc apply -f guest/managedcluster"
comment "TODO: wait for import.yaml secret to be created"
comment "generate import.yaml"
pe "export KUBECONFIG=$kubeconfig_name.kubeconfig"
pe "oc get secret -n kind-managed-cluster kind-managed-cluster-import -o jsonpath={.data.crds\\\.yaml} | base64 -d > import-crds.yaml"
pe "oc get secret -n kind-managed-cluster kind-managed-cluster-import -o jsonpath={.data.import\\\.yaml} | base64 -d > import.yaml"
comment "import KinD cluster"
pe "export KUBECONFIG=managed-cluster.kubeconfig"
pe "oc apply -f import-crds.yaml"
pe "oc apply -f import.yaml"
comment "TODO: wait for open-cluster-management-agent to be Ready"
pe "export KUBECONFIG=managed-cluster.kubeconfig"
pe "oc get pod -n open-cluster-management-agent"
comment "wait for cluster to be Available"
pe "export KUBECONFIG=$kubeconfig_name.kubeconfig"
pe "oc get managedcluster"
comment "HARD STUFF >.<"
comment "1. getting any webhook to work in this setup will be difficult hypershift itself is not able to sort out how to support OCP webhooks"
pe "export KUBECONFIG=$kubeconfig_name.kubeconfig"
pe "oc get validatingwebhookconfigurations"
pe "oc get mutatingwebhookconfigurations"
comment "2. getting Hive will be hard since hive expect to create job on managed cluster"
comment "3. getting Infrastructure Operator to work will be hard since it depends on the BareMetalOperator"
comment "4. Observability?"
comment "5. increase network complexity"