Last active
February 2, 2021 15:45
-
-
Save cdoan1/59426240d0f3fbe0326212a2c0ee07b7 to your computer and use it in GitHub Desktop.
Create OCP Cluster in OpenStack via RHACM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Refer to the `hiveutil` documenation for a complete argument listing see: | |
# https://github.com/openshift/hive/blob/master/docs/hiveutil.md | |
# | |
# or, hiveutil -help | |
# | |
# here, we're using an example external network, and getting a FIP | |
EXTERNAL_NETWORK=provider_net_cci_9 | |
FIP=$(openstack floating ip create $EXTERNAL_NETWORK) | |
# | |
# if you already have allocated a FIP | |
# FIP=${FIP:-10.0.106.68) | |
RELEASEIMAGE=quay.io/openshift-release-dev/ocp-release:4.5.2-x86_64 | |
# unique cluster name, we'll create a namespace with this name. | |
CLUSTERNAME=acmcdoan1 | |
# | |
# Use hiveutil to generate the install-config.yaml and clusterdeployment.yaml manifests | |
# | |
# NOTE: the basedomain and flavor can be variables as well, and specific to your environment | |
# | |
hiveutil create-cluster $CLUSTERNAME \ | |
--namespace=$CLUSTERNAME \ | |
--creds-file=clouds.yaml \ | |
--base-domain=example.com \ | |
--machine-network 192.168.0.0/16 \ | |
--cloud=openstack \ | |
--openstack-api-floating-ip=$FIP \ | |
--openstack-external-network=$EXTERNAL_NETWORK \ | |
--pull-secret-file=pull-secret.json \ | |
--ssh-private-key-file=openstack-sshkey \ | |
--ssh-public-key-file=openstack-sshkey.pub \ | |
--openstack-compute-flavor=ci.m4.xlarge \ | |
--release-image $RELEASEIMAGE -o yaml > $CLUSTERNAME-cluster.yaml | |
# hiveutil adds an initial line, remove it so we can apply the manifest | |
sed -i '' '/^time=/d' ./$CLUSTERNAME-cluster.yaml | |
# append the managedcluster and endpointconfig resources | |
cat > klusterlet.yaml <<EOF | |
--- | |
apiVersion: cluster.open-cluster-management.io/v1 | |
kind: ManagedCluster | |
metadata: | |
labels: | |
cloud: OpenStack | |
name: $CLUSTERNAME | |
vendor: OpenShift | |
name: $CLUSTERNAME | |
spec: | |
hubAcceptsClient: true | |
--- | |
apiVersion: agent.open-cluster-management.io/v1 | |
kind: KlusterletAddonConfig | |
metadata: | |
name: $CLUSTERNAME | |
namespace: $CLUSTERNAME | |
spec: | |
clusterName: $CLUSTERNAME | |
clusterNamespace: $CLUSTERNAME | |
clusterLabels: | |
cloud: OpenStack | |
vendor: OpenShift | |
purpose: development | |
environment: dev | |
applicationManager: | |
enabled: true | |
policyController: | |
enabled: true | |
searchCollector: | |
enabled: true | |
certPolicyController: | |
enabled: true | |
iamPolicyController: | |
enabled: true | |
version: "2.0" | |
EOF | |
# 3. create the namespace where cluster resources will be created | |
oc new-project $CLUSTERNAME | |
# 4. as cluster-admin on the hub, apply the manifests to trigger provisioning | |
oc apply -f $CLUSTERNAME-cluster.yaml -f klusterlet.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Creating OpenShift Cluster in OpenStack using RHACM
NOTE: if you want to use /etc/hosts for *.apps.clustername.domain, you can, but I did not test this flow. You can set the A Records up before you provision if you have the FIP.
hiveutils - I spent alot of time looking up examples of ClusterDeployment.yaml or install-config.yaml for OpenStack, but its just so much easier to use hiveutils to generate all the manifests required to pass to hive.
The hiveutil will create a clusterdeployment that references the install-config.yaml base64 encoded into a secret. You can modify that secret to change the characteristics of the provisioned cluster.
Sample Output