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 b7ae11c
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 286 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.

4 changes: 2 additions & 2 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 Down
11 changes: 6 additions & 5 deletions scripts/00_virtual.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ 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
dnf -y copr enable karmab/aicli
dnf -y install aicli
aicli create onprem

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
40 changes: 5 additions & 35 deletions scripts/02_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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

update-ca-trust extract
Expand All @@ -12,44 +12,14 @@ curl -Ls https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 > /u
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 %}
111 changes: 0 additions & 111 deletions scripts/07_deploy_openshift.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b7ae11c

Please sign in to comment.