Artikel ini akan menjelaskan cara menyediakan kluster OKD 4 pada satu mesin bare metal. Mesin tersebut akan menggunakan KVM untuk hypervisor dan IdM untuk server DNS. Untuk penyeimbang beban, kami akan menggunakan server Haproxy, untuk server web kami akan menggunakan httpd. Keduanya akan berjalan dalam kontainer podman lokal.
Lingkungan ini akan terdiri dari 3 master dan 3 pekerja yang menjalankan Fedora CoreOS. Server DNS akan menggunakan IdM dan RHEl 7.8 sebagai OS. Sistem dasar yang mengelola host KVM akan menjalankan Red Hat Enterprise Linux (RHEL 8).
Persyaratan Perangkat Keras
Persyaratan perangkat keras dapat ditemukan di sini .
setup — pastikan nama pengguna Anda diatur untuk sudoers
rhsm — pastikan sistem rhel Anda terdaftar di Red Hat
ansible — pastikan sistem rhel Anda diatur untuk berfungsi sebagai pengontrol ansible
host — pastikan sistem rhel Anda diatur sebagai host KVM
5. Perintah di bawah ini akan digunakan untuk menyebarkan server IdM Anda untuk digunakan sebagai DNS
$ ./qubinode-installer -p idm
6. Salin file vars OKD4 ke direktori vars
$ cp sampel/okd4_baremetal.yml buku pedoman/vars/okd4_baremetal.yml
Untuk detail lebih lanjut tentang okd4_baremetal.yml klik tautan ini .
7. Untuk menginstal OKD 4
$ ansible-playbook playbook/deploy_okd4.yml
Sekarang kita bisa mendapatkan info login sehingga kita bisa login ke cluster OKD kita
$ openshift-install --dir "okd4/" wait-for install-complete INFO Menunggu hingga 30 menit untuk klaster di https://api.qbn.cloud.qubinode-lab.com:6443 untuk menginisialisasi... INFO Menunggu hingga 10 menit untuk rute openshift-console dibuat... INFO Instalasi selesai! INFO Untuk mengakses klaster sebagai pengguna system:admin saat menggunakan 'oc', jalankan 'export KUBECONFIG=/home/admin/qubinode-installer/okd4/auth/kubeconfig' INFO Akses konsol web OpenShift di sini: https://console-openshift-console.apps.qbn.cloud.example-lab.com INFO Masuk ke konsol dengan pengguna: kubeadmin, kata sandi: mZqM9-xxyzQ-Gr3xP-wj45z
Berikut adalah langkah-langkah verifikasi yang dapat dilakukan.
Dapatkan status node
$ oc dapatkan node NAMA STATUS PERAN USIA VERSI compute-0 Pekerja siap 11m v1.17.1 compute-1 Pekerja siap 14m v1.17.1 compute-2 Pekerja siap 15m v1.17.1 master-0 Master siap 29m v1.17.1 master-1 Master siap 28m v1.17.1 master-2 Master siap 29m v1.17.1
Dapatkan Status Operator Cluster
$ oc get co NAMA VERSI TERSEDIA BERKEMBANG MENURUN SEJAK authentication 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 8m29s cloud-credential 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 32m cluster-autoscaler 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m console 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 6m53s csi-snapshot-controller Bahasa Indonesia: 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 13m dns 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m etcd 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m image-registry 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m ingress 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 14m insights 4.4.0-0.okd-2020-05-23-055148-beta5 Bahasa Indonesia: Benar Salah Salah 18m kube-apiserver 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m kube-controller-manager 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m kube-scheduler 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m kube-storage-version-migrator 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 14m machine-api 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m machine-config Bahasa Indonesia: 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m pasar 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m pemantauan 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 7m59d jaringan 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m penyetelan-simpul 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 25m openshift-apiserver 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m Bahasa Indonesia: openshift-controller-manager 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m openshift-samples 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 15m operator-lifecycle-manager 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m operator-lifecycle-manager-catalog 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m operator-lifecycle-manager-packageserver 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 19m Bahasa Indonesia: layanan-ca 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 25m layanan-katalog-apiserver 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 25m layanan-katalog-pengontrol-manajer 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 25m penyimpanan 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m
Berikut ini adalah beberapa langkah untuk terhubung ke kluster OKD. Kita harus mengarahkan ke server DNS agar dapat mengakses kluster.
Opsi 1
Perbarui /etc/resolv.conf pada mesin Linux Anda dengan menjalankan skrip di bawah ini.
Jika router rumah Anda dibangun pada openwrt atau menggunakan dnsmasq untuk DNS, Anda dapat meneruskannya semua entri dns untuk domain OKD Anda ke server IdM.
server=/lab.contoh/192.168.1.10
Ganti lab.example dan 192.168.1.10 dengan domain dan IP server IdM Anda. Ini akan meneruskan semua permintaan yang masuk ke lab.example ke server IdM 192.168.1.10. Pfsense juga menyediakan perilaku serupa saat Anda menggunakan resolver sebagai penyedia DNS.
If you want to run a local Red Hat OpenShift on your Laptop then this guide is written just for you. This guide is not meant for Production setup or any use where actual customer traffic is anticipated. CRC is a tool created for deployment of minimal OpenShift Container Platform 4 cluster and Podman container runtime on a local computer. This is fit for development and testing purposes only. Local OpenShift is mainly targeted at running on developers’ desktops. For deployment of Production grade OpenShift Container Platform use cases, refer to official Red Hat documentation on using the full OpenShift installer.
We also have guide on running Red Hat OpenShift Container Platform in KVM virtualization;
Here are the key points to note about Local Red Hat OpenShift Container platform using CRC:
The cluster is ephemeral
Both the control plane and worker node runs on a single node
The Cluster Monitoring Operator is disabled by default.
There is no supported upgrade path to newer OpenShift Container Platform versions
The cluster uses 2 DNS domain names, crc.testing and apps-crc.testing
crc.testing domain is for core OpenShift services and apps-crc.testing is for applications deployed on the cluster.
The cluster uses the 172 address range for internal cluster communication.
Requirements for running Local OpenShift Container Platform:
A computer with AMD64 and Intel 64 processor
Physical CPU cores: 4
Free memory: 9 GB
Disk space: 35 GB
1. Local Computer Preparation
We shall be performing this installation on a Red Hat Linux 9 system.
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 9.10 (Plow)
OS specifications are as shared below:
[jkmutai@crc ~]$ free -h
total used free shared buff/cache available
Mem: 31Gi 238Mi 30Gi 8.0Mi 282Mi 30Gi
Swap: 9Gi 0B 9Gi
[jkmutai@crc ~]$ grep -c ^processor /proc/cpuinfo
8
[jkmutai@crc ~]$ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether b2:42:4e:64:fb:17 brd ff:ff:ff:ff:ff:ff
altname enp0s18
inet 192.168.207.2/24 brd 192.168.207.255 scope global noprefixroute ens18
valid_lft forever preferred_lft forever
inet6 fe80::b042:4eff:fe64:fb17/64 scope link noprefixroute
valid_lft forever preferred_lft forever
For RHEL register system
If you’re performing this setup on RHEL system, use the commands below to register the system.
$ sudo subscription-manager register --auto-attach
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: <RH-USERNAME>
Password: <RH-PASSWORD>
The registered system name is: crc.example.com
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64
Status: Subscribed
The command will automatically associate any available subscription matching the system. You can also provide username and password in one command line.
You’ll run the crc setup command to create a new Red Hat OpenShift Local Cluster. All the prerequisites for using CRC are handled automatically for you.
$ crc setup
CRC is constantly improving and we would like to know more about usage (more details at https://developers.redhat.com/article/tool-data-collection)
Your preference can be changed manually if desired using 'crc config set consent-telemetry <yes/no>'
Would you like to contribute anonymous usage statistics? [y/N]: y
Thanks for helping us! You can disable telemetry with the command 'crc config set consent-telemetry no'.
INFO Using bundle path /home/crc/.crc/cache/crc_libvirt_4.15.17_amd64.crcbundle
INFO Checking if running as non-root
INFO Checking if running inside WSL2
INFO Checking if crc-admin-helper executable is cached
INFO Caching crc-admin-helper executable
INFO Using root access: Changing ownership of /home/jkmutai/.crc/bin/crc-admin-helper-linux
INFO Using root access: Setting suid for /home/jkmutai/.crc/bin/crc-admin-helper-linux
INFO Checking for obsolete admin-helper executable
INFO Checking if running on a supported CPU architecture
INFO Checking minimum RAM requirements
INFO Checking if crc executable symlink exists
INFO Creating symlink for crc executable
INFO Checking if Virtualization is enabled
INFO Checking if KVM is enabled
INFO Checking if libvirt is installed
INFO Installing libvirt service and dependencies
INFO Using root access: Installing virtualization packages
INFO Checking if user is part of libvirt group
INFO Adding user to libvirt group
INFO Using root access: Adding user to the libvirt group
INFO Checking if active user/process is currently part of the libvirt group
INFO Checking if libvirt daemon is running
WARN No active (running) libvirtd systemd unit could be found - make sure one of libvirt systemd units is enabled so that it's autostarted at boot time.
INFO Starting libvirt service
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl start libvirtd
INFO Checking if a supported libvirt version is installed
INFO Checking if crc-driver-libvirt is installed
INFO Installing crc-driver-libvirt
INFO Checking crc daemon systemd service
INFO Setting up crc daemon systemd service
INFO Checking crc daemon systemd socket units
INFO Setting up crc daemon systemd socket units
INFO Checking if systemd-networkd is running
INFO Checking if NetworkManager is installed
INFO Checking if NetworkManager service is running
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists
INFO Writing Network Manager config for crc
INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf
INFO Using root access: Changing permissions for /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf to 644
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl reload NetworkManager
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists
INFO Writing dnsmasq config for crc
INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/dnsmasq.d/crc.conf
INFO Using root access: Changing permissions for /etc/NetworkManager/dnsmasq.d/crc.conf to 644
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl reload NetworkManager
INFO Checking if libvirt 'crc' network is available
INFO Setting up libvirt 'crc' network
INFO Checking if libvirt 'crc' network is active
INFO Starting libvirt 'crc' network
INFO Checking if CRC bundle is extracted in '$HOME/.crc'
INFO Checking if /home/jkmutai/.crc/cache/crc_libvirt_4.15.17_amd64.crcbundle exists
INFO Getting bundle for the CRC executable
INFO Downloading crc_libvirt_4.15.17_amd64.crcbundle
CRC bundle is downloaded locally within few seconds / minutes depending on your network connectivity speed.
Once the system is correctly setup for using CRC, start the new Red Hat OpenShift Local instance:
$ crc start
INFO Checking if running as non-root
INFO Checking if running inside WSL2
INFO Checking if crc-admin-helper executable is cached
INFO Checking for obsolete admin-helper executable
INFO Checking if running on a supported CPU architecture
INFO Checking minimum RAM requirements
INFO Checking if crc executable symlink exists
INFO Checking if Virtualization is enabled
INFO Checking if KVM is enabled
INFO Checking if libvirt is installed
INFO Checking if user is part of libvirt group
INFO Checking if active user/process is currently part of the libvirt group
INFO Checking if libvirt daemon is running
INFO Checking if a supported libvirt version is installed
INFO Checking if crc-driver-libvirt is installed
INFO Checking crc daemon systemd socket units
INFO Checking if systemd-networkd is running
INFO Checking if NetworkManager is installed
INFO Checking if NetworkManager service is running
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists
INFO Checking if libvirt 'crc' network is available
INFO Checking if libvirt 'crc' network is active
INFO Loading bundle: crc_libvirt_4.15.17_amd64...
CRC requires a pull secret to download content from Red Hat.
You can copy it from the Pull Secret section of https://console.redhat.com/openshift/create/local.
Paste the contents of the Pull secret.
? Please enter the pull secret <PASTE-PULL-SECRET-FROM-REDHAT-PORTAL>
Local OpenShift cluster creation process should continue.
INFO Creating CRC VM for openshift 4.15.17...
INFO Generating new SSH key pair...
INFO Generating new password for the kubeadmin user
INFO Starting CRC VM for openshift 4.15.17...
INFO CRC instance is running with IP 192.168.130.11
INFO CRC VM is running
INFO Updating authorized keys...
INFO Configuring shared directories
INFO Check internal and public DNS query...
INFO Check DNS query from host...
INFO Verifying validity of the kubelet certificates...
INFO Starting kubelet service
INFO Waiting for kube-apiserver availability... [takes around 2min]
INFO Adding user's pull secret to the cluster...
INFO Updating SSH key to machine config resource...
INFO Waiting for user's pull secret part of instance disk...
INFO Changing the password for the kubeadmin user
INFO Updating cluster ID...
INFO Updating root CA cert to admin-kubeconfig-client-ca configmap...
INFO Starting openshift instance... [waiting for the cluster to stabilize]
INFO 3 operators are progressing: image-registry, network, openshift-controller-manager
[INFO 3 operators are progressing: image-registry, network, openshift-controller-manager
INFO 2 operators are progressing: image-registry, openshift-controller-manager
INFO Operator openshift-controller-manager is progressing
INFO Operator authentication is not yet available
INFO Operator kube-apiserver is progressing
INFO All operators are available. Ensuring stability...
INFO Operators are stable (2/3)...
INFO Operators are stable (3/3)...
INFO Adding crc-admin and crc-developer contexts to kubeconfig...
If creation was successful you should get output like below in your console.
Started the OpenShift cluster.
The server is accessible via web console at:
https://console-openshift-console.apps-crc.testing
Log in as administrator:
Username: kubeadmin
Password: yHhxX-fqAjW-8Zzw5-Eg2jg
Log in as user:
Username: developer
Password: developer
Use the 'oc' command line interface:
$ eval $(crc oc-env)
$ oc login -u developer https://api.crc.testing:6443
Virtual Machine created can be checked with virsh command:
$ sudo virsh list
Id Name State
----------------------
1 crc running
4. Manage cluster using crc commands
Update number of vCPUs available to the instance:
crc config set cpus <number>
Configure the memory available to the instance:
$ crc config set memory <number-in-mib>
Display status of the OpenShift cluster
## When running ###
$ crc status
CRC VM: Running
OpenShift: Running (v4.15.17)
Podman:
Disk Usage: 15.29GB of 32.74GB (Inside the CRC VM)
Cache Usage: 17.09GB
Cache Directory: /home/jkmutai/.crc/cache
## When Stopped ###
$ crc status
CRC VM: Stopped
OpenShift: Stopped (v4.15.17)
Podman:
Disk Usage: 0B of 0B (Inside the CRC VM)
Cache Usage: 17.09GB
Cache Directory: /home/jkmutai/.crc/cache
Get IP address of the running OpenShift cluster
$ crc ip
192.168.130.11
Open the OpenShift Web Console in the default browser
crc console
Accept SSL certificate warnings to access OpenShift dashboard.
Accept risk and continue
Authenticate with username and password given on screen after deployment of crc instance.
The following command can also be used to view the password for the developer and kubeadmin users:
If you want to permanently delete the instance, use:
crc delete
5. Configure oc environment
Let’s add oc executable our system’s PATH:
$ crc oc-env
export PATH="/home/jkmutai/.crc/bin/oc:$PATH"
# Run this command to configure your shell:
# eval $(crc oc-env)
$ vim ~/.bashrc
export PATH="/home/$USER/.crc/bin/oc:$PATH"
eval $(crc oc-env)
Logout and back in to validate it works.
$ exit
Check oc binary path after getting in to the system.
$ which oc
~/.crc/bin/oc/oc
$ oc get nodes
NAME STATUS ROLES AGE VERSION
crc-9jm8r-master-0 Ready master,worker 21d v1.24.0+9546431
Confirm this works by checking installed cluster version
$ oc get clusterversion
NAME VERSION AVAILABLE PROGRESSING SINCE STATUS
version 4.15.17 True False 20d Cluster version is 4.15.17
Note that the OpenShift Local reserves IP subnets for its internal use and they should not collide with your host network. These IP subnets are:
10.217.0.0/22
10.217.4.0/23
192.168.126.0/24
If your local system is behind a proxy, then define proxy settings using environment variable. See examples below:
crc config set http-proxyhttp://proxy.example.com:<port>
crc config set https-proxyhttp://proxy.example.com:<port>
crc config set no-proxy <comma-separated-no-proxy-entries>
If Proxy server uses SSL, set CA certificate as below:
crc config set proxy-ca-file <path-to-custom-ca-file>
6. Connecting to a remote instance
If the deployment is on a remote server, install CRC and start the instance using process in steps 1-3. With the cluster up and running, install HAProxy package:
You can use dnsmasq to connect a client machine to a remote server where OpenShift Container Platform cluster is running. This process assumes you’re using RHEL based system as client.
Install dnsmasq package:
sudo dnf install dnsmasq
Configure NetworkManager to use of dnsmasq for DNS resolution:
sudo tee /etc/NetworkManager/conf.d/use-dnsmasq.conf<<EOF
[main]
dns=dnsmasq
EOF
Add remote OpenShift Local Cluster DNS entries to the dnsmasq configuration:
$ sudo vim /etc/NetworkManager/dnsmasq.d/external-crc.conf
address=/apps-crc.testing/REMOTE_SERVER_IP_ADDRESS
address=/api.crc.testing/REMOTE_SERVER_IP_ADDRESS
If at one point you had local OpenShift client in your machine, then comment out any existing entries in /etc/NetworkManager/dnsmasq.d/crc.conf. These entries will conflict with the entries for the remote cluster.
Reload NetworkManager after making the changes:
sudo systemctl reload NetworkManager
We can then test by logging in to the remote cluster as the developer user with oc: