Skip to content

Commit

Permalink
migrate to aicli
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Dec 21, 2023
1 parent 747b5c9 commit 6860666
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 309 deletions.
40 changes: 40 additions & 0 deletions aicli_parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% if virtual_ctlplanes %}
{% set extra_ctlplanes = [] %}
{% for num in range(0, virtual_ctlplanes_number) %}
{% do extra_ctlplanes.append([]) %}
{% endfor %}
{% set ctlplanes = extra_ctlplanes + ctlplanes %}
{% endif %}
{% if virtual_workers and virtual_workers_deploy %}
{% set extra_workers = [] %}
{% for num in range(0, virtual_workers_number) %}
{% do extra_workers.append([]) %}
{% endfor %}
{% set workers = extra_workers + workers %}
{% endif %}
base_dns_domain: {{ domain }}
api_vip: {{ api_ip }}
ingress_vip: {{ ingress_ip }}
hosts:
{% for ctlplane in ctlplanes %}
{% set num = loop.index0|string %}
- name: {{ cluster }}-ctlplane-{{ num }}
role: master
url: {{ ctlplane['redfish_address']|default("CHANGEME:9000/redfish/v1/Systems/kcli/%s-ctlplane-%s" % (cluster, num)) }}
user: {{ ctlplane['bmc_user']|default(bmc_user) }}
password: {{ ctlplane['bmc_password']|default(bmc_password) }}
{% if 'disk' in ctlplane %}
disk: "/dev/{{ ctlplane['disk'] | basename }}"
{% endif %}
{% endfor %}
{% for worker in workers %}
{% set num = loop.index0|string %}
- name: {{ cluster }}-worker-{{ num }}
role: worker
url: {{ worker['redfish_address']|default("CHANGEME:9000/redfish/v1/Systems/kcli/%s-worker-%s" % (cluster, num)) }}
user: {{ worker['bmc_user']|default(bmc_user) }}
password: {{ worker['bmc_password']|default(bmc_password) }}
{% if 'disk' in worker %}
disk: "/dev/{{ worker['disk'] | basename }}"
{% endif %}
{% endfor %}
3 changes: 0 additions & 3 deletions bin/clean.sh

This file was deleted.

11 changes: 1 addition & 10 deletions envfiles/bashrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# .bashrc
{% set libvirt_user = 'root' if config_user == 'apache' else config_user %}
{% set libvirt_ip = config_host if config_host not in ['127.0.0.1', 'localhost'] else baremetal_net|local_ip %}
{% set libvirt_ip = libvirt_ip|replace(':', '-') + '.sslip.io' %}
{% set libvirt_url = 'qemu+ssh://' + libvirt_user + '@' + libvirt_ip + '/system' %}

# User specific aliases and functions

Expand All @@ -14,13 +10,8 @@ alias mv='mv -i'
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export KUBECONFIG=/root/ocp/auth/kubeconfig
export OS_CLOUD=metal3-bootstrap
export KUBECONFIG=/root/kubeconfig.{{ kubeconfig }}
export PATH=/usr/local/bin:/root/bin:$PATH
export LIBVIRT_DEFAULT_URI={{ libvirt_url }}
export REGISTRY_PASSWORD={{ disconnected_password }}
export REGISTRY_USER={{ disconnected_user }}

alias hypershift='podman run -it --rm --security-opt label=disable --entrypoint=/usr/bin/hypershift -e KUBECONFIG=/k/kubeconfig -v /root/ocp/auth:/k quay.io/hypershift/hypershift-operator:latest'

export PYTHONUNBUFFERED=true
5 changes: 5 additions & 0 deletions kcli_pre.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

# OFFLINE TOKEN
{% if saas %}
[ ! -f {{ offlinetoken }} ] && echo offlinetoken not found in {{ offlinetoken }} && exit 1
{% endif %}

# NETWORK CHECK
{% if baremetal_cidr == None %}
echo baremetal_cidr not set. No network, no party!
Expand Down
10 changes: 7 additions & 3 deletions plans/kcli_plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% if deploy_openshift %}
notifyscript: {{ notifyscript }}
{% elif launch_steps %}
notifycmd: /root/bin/openshift-install version
notifycmd: aicli list cluster
{% else %}
notifycmd: echo machine $(hostname) ready at $(hostname -I)
{% endif %}
Expand All @@ -43,7 +43,7 @@
disks:
- {{ installer_disk_size or disk_size }}
files:
- install-config.yaml
- aicli_parameters.yml
{% if motd != None %}
- path: /etc/motd
origin: {{ motd }}
Expand All @@ -61,7 +61,11 @@
- mirror-registry/quay_haproxy.cfg
{% endif %}
- origin: {{ pullsecret }}
path: /root/openshift_pull.json
path: /root/openshift_pull.json
{% if saas %}
- origin: {{ offlinetoken }}
path: /root/.aicli/offlinetoken.txt
{% endif %}
- path: /etc/systemd/system/registry.service
origin: bin/registry.service
{% for ca in cas %}
Expand Down
15 changes: 3 additions & 12 deletions plans/kcli_plan_default.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
info: |
This deploys a vm where
- openshift-baremetal-install is downloaded
- caches rhcos bootstrap image
- aicli is downloaded
- stop the nodes to deploy through redfish
- launch the install against a set of baremetal nodes (and optionally virtual ctlplanes)
It can be used with a centos8stream or rhel8 vm (which required to set rhn credentials in your kcli config)
Expand Down Expand Up @@ -39,12 +38,6 @@ image_url:
numcpus: 16
rhnregister: true
rhnwait: 30
baremetal_noprovisioning_ip:
baremetal_noprovisioning_bootstrap_ip:
baremetal_bootstrap_mac:
baremetal_bootstrap_ip:
baremetal_bootstrap_os_image:
baremetal_cluster_os_image:
bmc_user: root
bmc_password: calvin
bmc_reset: false
Expand All @@ -53,7 +46,6 @@ baremetal_macs: []
baremetal_ips: []
pullsecret: openshift_pull.json
notifyscript: scripts/notify.sh
virtual_protocol: ipmi
notify: false
launch_steps: true
deploy_openshift: true
Expand Down Expand Up @@ -87,8 +79,6 @@ cas: []
nbde: false
ntp: false
ntp_server: 0.rhel.pool.ntp.org
model: dell
patch_rhcos_image: false
apps: []
localhost_fix: false
virtual_ctlplanes_static_network: False
Expand All @@ -105,4 +95,5 @@ wait_for_workers: true
wait_for_workers_number:
wait_for_workers_timeout: 3600
manifests_dir: manifests
wait_for_workers_exit_if_error: false
saas: true
offlinetoken: ~/.aicli/offlinetoken.txt
7 changes: 2 additions & 5 deletions scripts/00_virtual.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ ssh-keyscan -H {{ config_host if config_host not in ['127.0.0.1', 'localhost'] e
echo -e "Host=*\nStrictHostKeyChecking=no\n" > /root/.ssh/config
IP=$(ip -o addr show $PRIMARY_NIC | head -1 | awk '{print $4}' | cut -d "/" -f 1 | head -1)
echo $IP | grep -q ':' && IP=[$IP]
sed -i "s/CHANGEME/$IP/" /root/install-config.yaml
sed -i "s/CHANGEME/$IP/" /root/aicli_parameters.yml

api_vip=$(grep apiVIP /root/install-config.yaml | sed s/apiVIP:// | xargs)
cluster=$(grep -m 1 name /root/install-config.yaml | awk -F: '{print $2}' | xargs)
domain=$(grep baseDomain /root/install-config.yaml | awk -F: '{print $2}' | xargs)
echo $api_vip api.$cluster.$domain >> /etc/hosts
echo {{ api_ip }} api.{{ cluster }}.{{ domain }} >> /etc/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@ set -euo pipefail
[ -d /root/manifests ] || mkdir -p /root/manifests
ssh-keyscan -H {{ config_host if config_host not in ['127.0.0.1', 'localhost'] else baremetal_net|local_ip }} >> ~/.ssh/known_hosts
echo -e "Host=*\nStrictHostKeyChecking=no\n" > ~/.ssh/config

{% if not disconnected %}
PULLSECRET=$(cat /root/openshift_pull.json | tr -d [:space:])
echo -e "pullSecret: |\n $PULLSECRET" >> /root/install-config.yaml
{% endif %}
SSHKEY=$(cat /root/.ssh/id_rsa.pub)
echo -e "sshKey: |\n $SSHKEY" >> /root/install-config.yaml
47 changes: 12 additions & 35 deletions scripts/02_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,30 @@
set -euo pipefail

dnf -y copr enable karmab/kcli
dnf -y install libvirt-libs libvirt-client ipmitool mkisofs tmux make git bash-completion vim-enhanced kcli
dnf -y install libvirt-libs libvirt-client mkisofs tmux make git bash-completion vim-enhanced kcli
dnf -y install python3

dnf -y copr enable karmab/aicli
dnf -y install aicli
{% if not saas %}
aicli create onprem
export AI_URL=127.0.0.1:8090
{% endif %}

update-ca-trust extract

curl -Ls https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 > /usr/bin/jq
chmod u+x /usr/bin/jq

cd /root/bin
curl -k -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz > oc.tar.gz
tar zxf oc.tar.gz
rm -rf oc.tar.gz
kcli download oc
mv oc /usr/bin
chmod +x /usr/bin/oc

curl -L https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl > /usr/bin/kubectl
kcli download kubectl
mv kubectl /usr/bin
chmod u+x /usr/bin/kubectl

export PULL_SECRET="/root/openshift_pull.json"
{% if version in ['dev-preview', 'stable'] %}
{% set tag = tag|string %}
{% if tag.split('.')|length > 2 %}
TAG={{ tag }}
{% else %}
TAG={{"latest-" + tag }}
{% endif %}
OCP_REPO={{ 'ocp-dev-preview' if version == 'dev-preview' else 'ocp' }}
export OPENSHIFT_RELEASE_IMAGE=$(curl -s https://mirror.openshift.com/pub/openshift-v4/clients/$OCP_REPO/$TAG/release.txt | grep 'Pull From: quay.io' | awk -F ' ' '{print $3}')
{% elif version == 'latest' %}
export OPENSHIFT_RELEASE_IMAGE=$(curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}-{{ tag }}/release.txt | grep 'Pull From: quay.io' | awk -F ' ' '{print $3}')
{% elif version == 'ci' %}
{% if openshift_image == None %}
{% set openshift_image = tag if '/' in tag|string else "registry.ci.openshift.org/ocp/release:" + tag|string %}
{% endif %}
export OPENSHIFT_RELEASE_IMAGE={{ openshift_image }}
{% elif version == 'nightly' %}
export OPENSHIFT_RELEASE_IMAGE=$(curl -s https://amd64.ocp.releases.ci.openshift.org/api/v1/releasestream/{{ tag|string }}.0-0.nightly/latest | jq -r .pullSpec)
{% endif %}
oc adm release extract --registry-config $PULL_SECRET --command=oc --to /tmp $OPENSHIFT_RELEASE_IMAGE
mv /tmp/oc /root/bin
oc adm release extract --registry-config $PULL_SECRET --command=openshift-baremetal-install --to /root/bin $OPENSHIFT_RELEASE_IMAGE
ln -s /root/bin/openshift-baremetal-install /root/bin/openshift-install
echo $OPENSHIFT_RELEASE_IMAGE > /root/version.txt

curl -s -L https://github.com/itaysk/kubectl-neat/releases/download/v2.0.3/kubectl-neat_linux_amd64.tar.gz | tar xvz -C /usr/bin/

dnf copr enable zaneb/autopage -y
dnf install podman skopeo python3-bmo-log-parse -y
dnf -y install podman skopeo

oc completion bash >>/etc/bash_completion.d/oc_completion
56 changes: 0 additions & 56 deletions scripts/03_cache.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,6 @@ EXTRA_OCP_RELEASE={{ release.split(':')[1] }}
oc adm release mirror -a $PULL_SECRET --from={{ release }} --to-release-image=${LOCAL_REG}/openshift/release-images:${EXTRA_OCP_RELEASE} --to=${LOCAL_REG}/openshift/release
{% endfor %}

if [ "$(grep imageContentSources /root/install-config.yaml)" == "" ] ; then
cat << EOF >> /root/install-config.yaml
imageContentSources:
- mirrors:
- $REGISTRY_NAME:$REGISTRY_PORT/openshift/release
source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
- mirrors:
- $REGISTRY_NAME:$REGISTRY_PORT/openshift/release-images
{% if version == 'ci' %}
source: registry.ci.openshift.org/ocp/release
{% elif version == 'nightly' %}
source: quay.io/openshift-release-dev/ocp-release-nightly
{% else %}
source: quay.io/openshift-release-dev/ocp-release
{% endif %}
EOF
else
IMAGECONTENTSOURCES="- mirrors:\n - $REGISTRY_NAME:$REGISTRY_PORT/openshift/release\n source: quay.io/openshift-release-dev/ocp-v4.0-art-dev\n- mirrors:\n - $REGISTRY_NAME:$REGISTRY_PORT/openshift/release-images\n source: registry.ci.openshift.org/ocp/release"
sed -i "/imageContentSources/a${IMAGECONTENTSOURCES}" /root/install-config.yaml
fi

if [ "$(grep additionalTrustBundle /root/install-config.yaml)" == "" ] ; then
echo "additionalTrustBundle: |" >> /root/install-config.yaml
sed -e 's/^/ /' /opt/registry/certs/domain.crt >> /root/install-config.yaml
else
LOCALCERT="-----BEGIN CERTIFICATE-----\n $(grep -v CERTIFICATE /opt/registry/certs/domain.crt | tr -d '[:space:]')\n -----END CERTIFICATE-----"
sed -i "/additionalTrustBundle/a${LOCALCERT}" /root/install-config.yaml
sed -i 's/^-----BEGIN/ -----BEGIN/' /root/install-config.yaml
fi
echo $REGISTRY_NAME:$REGISTRY_PORT/openshift/release-images:$OCP_RELEASE > /root/version.txt

if [ "$(grep pullSecret /root/install-config.yaml)" == "" ] ; then
DISCONNECTED_PULLSECRET=$(cat /root/disconnected_pull.json | tr -d [:space:])
echo -e "pullSecret: |\n $DISCONNECTED_PULLSECRET" >> /root/install-config.yaml
fi

cp /root/machineconfigs/99-operatorhub.yaml /root/manifests

{% for image in disconnected_extra_images %}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions scripts/06_deploy_openshift.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -euo pipefail

cd /root
export PATH=/root/bin:$PATH
export HOME=/root
export KUBECONFIG=/root/kubeconfig.{{ cluster }}
[ -d /root/manifests ] || mkdir -p /root/manifests

{% for ctlplane in ctlplanes %}
kcli stop baremetal-host -P url={{ ctlplane["redfish_address"]|default("127.0.0.1:9000/redfish/v1/Systems/kcli/%s-ctlplane-%s" % (cluster, num)) }} -P user={{ bmc_user }} -P password={{ bmc_password }}
{% endfor %}
{% for worker in workers %}
kcli stop baremetal-host -P url={{ worker["redfish_address"]|default("127.0.0.1:9000/redfish/v1/Systems/kcli/%s-worker-%s" % (cluster, num)) }} -P user={{ bmc_user }} -P password={{ bmc_password }}
{% if bmc_reset %}
kcli reset baremetal-host -P url={{ worker["redfish_address"]|default("127.0.0.1:9000/redfish/v1/Systems/kcli/%s-worker-%s" % (cluster, num)) }} -P user={{ bmc_user }} -P password={{ bmc_password }}
{% endif %}
{% endfor %}

{% if localhost_fix %}
cp /root/machineconfigs/99-localhost-fix*.yaml /root/manifests
{% endif %}
{% if monitoring_retention != None %}
cp /root/machineconfigs/99-monitoring.yaml /root/manifests
{% endif %}
find manifests -type f -empty -print -delete
grep -q "{{ api_ip }} api.{{ cluster }}.{{ domain }}" /etc/hosts || echo {{ api_ip }} api.{{ cluster }}.{{ domain }} >> /etc/hosts

aicli create deployment {{ cluster }}
aicli download kubeconfig --path /root
{% if virtual_ctlplanes %}
for node in $(oc get nodes --selector='node-role.kubernetes.io/master' -o name) ; do
oc label $node node-role.kubernetes.io/virtual=""
done
{% endif %}
Loading

0 comments on commit 6860666

Please sign in to comment.