Update deployment scritps

* remove kind and kubectl installation scripts
  * add prerequsite script which takes care of installing docker, make
    kind, kubectl, curl, wget and pip3
  * update playbook and zuul job to use new scripts
  * update README.md

Signed-off-by: Sreejith Punnapuzha <Sreejith.Punnapuzha@outlook.com>
Change-Id: Ie085b0f5e8c8246b5c812f8b5e13635e65ea9242
This commit is contained in:
Sreejith Punnapuzha 2021-05-18 10:49:19 -05:00
parent 8c63e1fc2b
commit cbfdd0cdee
7 changed files with 77 additions and 48 deletions

View File

@ -21,10 +21,9 @@ git clone https://opendev.org/airship/hostconfig-operator.git
cd hostconfig-operator
```
2. To install kind, kubectl and operator-sdk utilities
2. To install docker, kind, kubectl and necessary utilities
```
./tools/deployment/00_install_kind.sh
./tools/deployment/01_install_kubectl.sh
./tools/deployment/00_install_prerequsite.sh
```
3. Create hostconfig kind cluster

View File

@ -15,8 +15,7 @@
- name: "set default gate scripts"
set_fact:
gate_scripts_default:
- ./tools/deployment/00_install_kind.sh
- ./tools/deployment/01_install_kubectl.sh
- ./tools/deployment/00_install_prerequsite.sh
- ./tools/deployment/10_create_hostconfig_cluster.sh
- ./tools/deployment/20_configure_ssh_on_nodes.sh
- ./tools/deployment/30_create_labels.sh

View File

@ -1,27 +0,0 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This downloads kind, puts it in a temp directory, and prints the directory
set -e
KIND_VERSION="v0.8.1"
echo "Installing Kind Version $KIND_VERSION"
: ${KIND_URL:="https://kind.sigs.k8s.io/dl/$KIND_VERSION/kind-$(uname)-amd64"}
TMP=$(mktemp -d)
KIND="${TMP}/kind"
wget -O ${KIND} ${KIND_URL}
chmod +x ${KIND}
sudo cp ${KIND} /usr/local/bin

View File

@ -0,0 +1,64 @@
#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This downloads kind, puts it in a temp directory, and prints the directory
set -xe
export KIND_VERSION=${KIND_VERSION:="v0.8.1"}
export KIND_URL=${KIND_URL:="https://kind.sigs.k8s.io/dl/$KIND_VERSION/kind-$(uname)-amd64"}
export KUBE_VERSION=${KUBE_VERSION:="v1.18.6"}
export KUBE_URL=${KUBE_URL:="https://storage.googleapis.com"}
export HCO_WS=${HCO_WS:-$PWD}
export TMP_DIR=${TMP_DIR:-"$(dirname $(mktemp -u))"}
ANSIBLE_CFG=${ANSIBLE_CFG:-"${HOME}/.ansible.cfg"}
ANSIBLE_HOSTS=${ANSIBLE_HOSTS:-"${TMP_DIR}/ansible_hosts"}
PLAYBOOK_CONFIG=${PLAYBOOK_CONFIG:-"${TMP_DIR}/config.yaml"}
echo "Installing Necessary OS Packages"
pkg_check() {
for pkg in $@; do
sudo dpkg -s $pkg &> /dev/null || sudo DEBIAN_FRONTEND=noninteractive apt -y install $pkg
done
}
pkg_check curl wget python3-pip python3-setuptools ca-certificates make
echo "Installing Kind Version $KIND_VERSION"
sudo wget -O /usr/local/bin/kind ${KIND_URL}
sudo chmod +x /usr/local/bin/kind
# Install kubectl
echo "Installing Kubectl Version $KUBE_VERSION"
sudo wget -O /usr/local/bin/kubectl \
"${KUBE_URL}"/kubernetes-release/release/"${KUBE_VERSION}"/bin/linux/amd64/kubectl
sudo chmod +x /usr/local/bin/kubectl
mkdir -p "$TMP_DIR"
envsubst <"${HCO_WS}/tools/deployment/config_template.yaml" > "$PLAYBOOK_CONFIG"
PACKAGES="ansible netaddr"
if [[ -z "${http_proxy}" ]]; then
sudo pip3 install $PACKAGES
else
sudo pip3 --proxy "${http_proxy}" install $PACKAGES
fi
echo "primary ansible_host=localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3" > "$ANSIBLE_HOSTS"
printf "[defaults]\nroles_path = %s/roles\n" "$HCO_WS" > "$ANSIBLE_CFG"
ansible-playbook -i "$ANSIBLE_HOSTS" \
playbooks/airship-hostconfig-operator-deploy-docker.yaml \
-e @"$PLAYBOOK_CONFIG"

View File

@ -15,4 +15,4 @@ set -xe
kind delete cluster --name hostconfig
sudo docker rmi -f $(sudo docker images --all -q | xargs -I{} sudo bash -c 'if docker image inspect {} | grep -q kind; then echo {} ; fi')
rm -rf ssh
rm -rf ssh ~/.ansible.cfg

View File

@ -1,5 +1,3 @@
#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -12,13 +10,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -xe
: ${KUBE_VERSION:="v1.18.6"}
# Install kubectl
URL="https://storage.googleapis.com"
sudo wget -O /usr/local/bin/kubectl \
"${URL}"/kubernetes-release/release/"${KUBE_VERSION}"/bin/linux/amd64/kubectl
sudo chmod +x /usr/local/bin/kubectl
---
local_src_dir: "$HCO_WS"
ansible_user: root
proxy:
enabled: "$USE_PROXY"
http: "$HTTP_PROXY"
https: "$HTTPS_PROXY"
noproxy: "$NO_PROXY"

View File

@ -13,7 +13,6 @@
- job:
name: airship-hostconfig-operator-test
nodeset: airship-hostconfig-single-node
pre-run: playbooks/airship-hostconfig-operator-deploy-docker.yaml
timeout: 3600
run: playbooks/airship-hostconfig-operator.yaml
post-run:
@ -21,8 +20,7 @@
attempts: 1
vars:
gate_scripts:
- ./tools/deployment/00_install_kind.sh
- ./tools/deployment/01_install_kubectl.sh
- ./tools/deployment/00_install_prerequsite.sh
- ./tools/deployment/10_create_hostconfig_cluster.sh
- ./tools/deployment/20_configure_ssh_on_nodes.sh
- ./tools/deployment/30_create_labels.sh