Git Product home page Git Product logo

cluster-deployment-automation's Introduction

Cluster Deployment Automation

Automate deployment of OpenShift clusters in different configurations. The main functionality is showcased below. The distribution specific steps assume a RHEL/Fedora based distribution is used. Also, the instructions below make the assumption that everything is run as root from the repository root directory. Keep in mind that the deployment process will require your pull secret (by default this should be stored at {cwd}/pull_secret.json). This can be obtained from Red Hat OpenShift.

Install Software and Python Packages, Start a Python Virtual Environment and Setup

NOTE: Requires Python3.11 or higher

dnf install -y python3.11
python3.11 -m venv ocp-venv
source ocp-venv/bin/activate
./dependencies.sh
usermod -a -G root qemu

# Ensure having a suitable SSH key
[ -f ~/.ssh/id_ed25519 ] || ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519

Activate and deactivate Python virtual environment

source ocp-venv/bin/activate
...
deactivate

Generate a baremetal worker cluster configuration file (1)

NOTE: Replace ... with your specific information.

cat > cluster.yaml << EOF
clusters:
  - name : "mycluster"
    api_vip: "192.168.122.99"
    ingress_vip: "192.168.122.101"
    masters:
    - name: "mycluster-master-1"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.41"
    - name: "mycluster-master-2"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.42"
    - name: "mycluster-master-3"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.43"
    workers:
    - name: "mycluster-worker-1"
      kind: "physical"
      node: "..."
      bmc_user: "root"
      bmc_password: "..."
      bmc: "hostname or ip"
EOF

Generate a vm worker cluster configuration file (2)

cat > cluster.yaml << EOF
clusters:
  - name : "vm"
    api_vip: "192.168.122.99"
    ingress_vip: "192.168.122.101"
    kubeconfig: "/root/kubeconfig.vm"
    masters:
    - name: "vm-master-1"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.141"
    - name: "vm-master-2"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.142"
    - name: "vm-master-3"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.143"
    workers:
    - name: "vm-worker-1"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.144"
      bmc: "hostname or ip"
    - name: "vm-worker-2"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.145"
      bmc: "hostname or ip"
EOF

Generate a cluster configuration file that uses OVN rebuilt from source (3)

cat > cluster.yaml << EOF
clusters:
  - name : "vm"
    api_vip: "192.168.122.99"
    ingress_vip: "192.168.122.101"
    kubeconfig: "/root/kubeconfig.vm"
    masters:
    - name: "vm-master-1"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.141"
    - name: "vm-master-2"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.142"
    - name: "vm-master-3"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.143"
    workers:
    - name: "vm-worker-1"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.144"
      bmc: "hostname or ip"
    - name: "vm-worker-2"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.145"
      bmc: "hostname or ip"
    postconfig:
    - name: "ovn_custom"   # Rebuilds OVN from upstream ovn-org/ovn code.
    - name: "ovnk8s"       # Rolls out the ovn-k daemonset using the new image.
      image: "localhost/ovnk-custom-image:dev"
EOF

Generate a vm Single Node OpenShift (SNO) cluster configuration file (4)

cat > cluster.yaml << EOF
clusters:
  - name : "vm-sno"
    masters:
    - name: "sno-master"
      kind: "vm"
      node: "localhost"
      ip: "192.168.122.41"
EOF

Start the installation

source ocp-venv/bin/activate
python cda.py cluster.yaml deploy
deactivate

Install the latest 4.x openshift-client (optional)

The scripts don't rely on the OpenShift Client (oc) being installed locally. For a better user experience it might still be a good idea to install the latest 4.x version:

pushd /tmp/
wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz
tar xf openshift-client-linux.tar.gz oc
rm openshift-client-linux.tar.gz
mv oc /usr/bin/oc
popd

Set the kubeconfig after a successful installation

NOTE: By default, The kubeconfig file is generated in the current working directory unless specified and follows the convention kubeconfig.<cluster-name>:

export KUBECONFIG=/root/kubeconfig.vm

We can now access the cluster, e.g.:

# oc get nodes
NAME          STATUS   ROLES                         AGE    VERSION
vm-master-1   Ready    control-plane,master,worker   4d1h   v1.25.4+77bec7a
vm-master-2   Ready    control-plane,master,worker   4d1h   v1.25.4+77bec7a
vm-master-3   Ready    control-plane,master,worker   4d1h   v1.25.4+77bec7a
vm-worker-1   Ready    worker                        4d1h   v1.25.4+77bec7a
vm-worker-2   Ready    worker                        4d1h   v1.25.4+77bec7a

cluster-deployment-automation's People

Contributors

bn222 avatar saldaniele avatar thom311 avatar wizhaoredhat avatar dceara avatar simonartxavier avatar zinkelburger avatar almusil avatar vrindle avatar samd2021 avatar atenart avatar chaudron avatar liuhangbin avatar tsorya avatar igsilya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.