Created
June 9, 2022 06:07
-
-
Save ralvares/22b76bcfcb8b149c2ded81fd9a8743a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#LOGIN TO HUB CLUSTER | |
oc login | |
#Create a cluster to Import | |
export CLUSTER_NAME=sno-autoimport | |
oc new-project ${CLUSTER_NAME} | |
oc label namespace ${CLUSTER_NAME} cluster.open-cluster-management.io/managedCluster=${CLUSTER_NAME} | |
oc apply -f - << EOF | |
apiVersion: cluster.open-cluster-management.io/v1 | |
kind: ManagedCluster | |
metadata: | |
name: ${CLUSTER_NAME} | |
spec: | |
hubAcceptsClient: true | |
EOF | |
oc apply -f - << EOF | |
apiVersion: agent.open-cluster-management.io/v1 | |
kind: KlusterletAddonConfig | |
metadata: | |
name: ${CLUSTER_NAME} | |
namespace: ${CLUSTER_NAME} | |
spec: | |
clusterName: ${CLUSTER_NAME} | |
clusterNamespace: ${CLUSTER_NAME} | |
applicationManager: | |
enabled: true | |
certPolicyController: | |
enabled: true | |
clusterLabels: | |
cloud: auto-detect | |
vendor: auto-detect | |
iamPolicyController: | |
enabled: true | |
policyController: | |
enabled: true | |
searchCollector: | |
enabled: true | |
version: 2.2.0 | |
EOF | |
#Expoert CRDs and Import definitions | |
oc get secret ${CLUSTER_NAME}-import -n ${CLUSTER_NAME} -o jsonpath={.data.crds\\.yaml} | base64 --decode > klusterlet-crd.yaml | |
oc get secret ${CLUSTER_NAME}-import -n ${CLUSTER_NAME} -o jsonpath={.data.import\\.yaml} | base64 --decode > import.yaml | |
#Create the ignition files | |
mkdir /root/sno | |
openshift-baremetal-install --dir=/root/sno create manifests | |
#Copy the ACM files to the manifest directory | |
cp -rf /root/klusterlet-crd.yaml /root/sno/manifests/01-klusterlet-crd.yaml | |
cd /root/sno/manifests | |
#Split the import.yaml file in multiples #Single file wont work | |
csplit /root/import.yaml --prefix='02-acm-import-cluster' --suffix-format='%03d.yaml' --elide-empty-files /---/ '{*}' | |
#Delete this file since it is empty. | |
rm -rf 02-acm-import-cluster000.yaml | |
#Generate the single-node-ign file | |
openshift-baremetal-install --dir=/root/sno create single-node-ignition-config | |
#Clean the iso media. | |
coreos-installer iso kargs reset /var/lib/libvirt/images/rhcos-live.x86_64.iso | |
coreos-installer iso ignition remove /var/lib/libvirt/images/rhcos-live.x86_64.iso | |
For reference: https://gist.github.com/ralvares/976dce493b43c498cf781f8b8dff28d3 - SNO with staticip and nip.io | |
#Use the coreos-installer to embed ign files and staticIP if you wish | |
coreos-installer iso ignition embed -fi /root/sno/bootstrap-in-place-for-live-iso.ign /var/lib/libvirt/images/rhcos-live.x86_64.iso | |
coreos-installer iso kargs modify -a "console=ttyS0 rd.neednet=1 ip=${IP}::${GATEWAY}:${NETMASK}:${HOSTNAME}:${INT}:none nameserver=${DNS}" /var/lib/libvirt/images/rhcos-live.x86_64.iso | |
Have fun :) | |
virt-install --name="master-sno" --vcpus=4 --ram=16384 --disk path=/var/lib/libvirt/images/master-sno.qcow2,bus=sata,size=120 --network network=default,model=virtio --boot menu=on --console pty,target_type=serial --cpu host-passthrough --cdrom /var/lib/libvirt/images/rhcos-live.x86_64.iso & | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment