Are you looking to set up a single node Openshift cluster? Maybe on AWS EC2 or Microsoft Azure VM? I am also like you who had really struggled to set up Openshift lab environment with lessor cost or no cost. As we all know RedHat Openshift 3.x release supports the single node cluster concept and finally set up a one on AWS EC2 instance. Kubernetes is keep evolving and bringing more and more developers towards this robust orchestration platform. Openshift 3.11 is nearing EOL and organizations are speeding up to migrate the cluster to Openshift 4.x. Hope this article will help you to set up OKD 3.11 playground.
Note: OKD is a upstream project of Red Hat openshift.
1. Launch RHEL 7.x instance from any of your favorite cloud service providers. I have used AWS EC2.
2. Login to the system using root user . Update the system to the latest patch level.
[root@ip-172-31-39-253 yum.repos.d]# yum update -y
3. Create a Red Hat developer account if not exists.
4. Register the system using the developer account.
[root@ip-172-31-39-253 yum.repos.d]# subscription-manager register
5. Check the subscription manager status.
[root@ip-172-31-34-124 ~]# subscription-manager refresh All local data refreshed [root@ip-172-31-34-124 ~]# subscription-manager attach --auto All installed products are covered by valid entitlements. No need to update subscriptions at this time. Installed Product Current Status: Product Name: Red Hat Enterprise Linux Server Status: Subscribed [root@ip-172-31-34-124 ~]#
6. Install the following packages.
[root@ip-172-31-34-124 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 wget
7. Add the docker repo.
[root@ip-172-31-34-124 ~]# yum-config-manager --add-repo https:// download.docker.com/linux/centos/docker-ce.repo
8. Enable the extra RPMs.
[root@ip-172-31-34-124 ~]# subscription-manager repos —enable=rhel-7-serverextras-rpms
Install and configure Docker
9. Install docker and docker cli
[root@ip-172-31-34-124 ~]# yum install -y docker-ce docker-ce-cli containerd.io
10. Create the following directories and files.
[root@ip-172-31-34-124 ~]# mkdir -p /etc/containers [root@ip-172-31-34-124 ~]# [root@ip-172-31-34-124 ~]# cat /etc/containers/registries.conf [registries.insecure] registries = ['172.30.0.0/16'] [root@ip-172-31-34-124 ~]# [root@ip-172-31-34-124 ~]# cat /etc/docker/daemon.json { "insecure-registries": [ "172.30.0.0/16" ] } [root@ip-172-31-34-124 ~]#
11. Reload the system daemon and restart the docker service.
[root@ip-172-31-34-124 ~]# systemctl daemon-reload [root@ip-172-31-34-124 ~]# systemctl restart docker [root@ip-172-31-34-124 ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2022-03-09 15:29:23 UTC; 10s ago Docs: https://docs.docker.com Main PID: 2547 (dockerd) Tasks: 9 Memory: 30.2M CGroup: /system.slice/docker.service └─2547 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/ containerd.sock
12. Enable the IP forward
[root@ip-172-31-34-124 ~]# echo "net.ipv4.ip_forward = 1" | tee -a /etc/sysctl.conf net.ipv4.ip_forward = 1 [root@ip-172-31-34-124 ~]# sysctl -p net.ipv4.ip_forward = 1
Download and Install OC & Kubectl binaries:
13. Download oc & Kubectl binaries
[root@ip-172-31-34-124 ~]# wget https://github.com/openshift/origin/releases/ download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58blinux-64bit.tar.gz --2022-03-09 15:36:29-- https://github.com/openshift/origin/releases/ download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58blinux-64bit.tar.gz Resolving github.com (github.com)... 140.82.113.4 Connecting to github.com (github.com)|140.82.113.4|:443... connected. HTTP request sent, awaiting response... 302 Found HTTP request sent, awaiting response... 200 OK Length: 56507103 (54M) [application/octet-stream] Saving to: ‘openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz’ 100% [============================================================================ ============================================================================= ========>] 56,507,103 80.0MB/s in 0.7s 2022-03-09 15:36:30 (80.0 MB/s) - ‘openshift-origin-client-toolsv3.11.0-0cbc58b-linux-64bit.tar.gz’ saved [56507103/56507103] [root@ip-172-31-34-124 ~]# ls -lrt total 55200 -rw-------. 1 root root 7466 Apr 22 2020 original-ks.cfg -rw-------. 1 root root 8180 Apr 22 2020 anaconda-ks.cfg -rw-r--r--. 1 root root 56507103 Dec 7 08:29 openshift-origin-client-toolsv3.11.0-0cbc58b-linux-64bit.tar.gz
14. Extract the downloaded file.
[root@ip-172-31-34-124 ~]# tar xf openshift-origin-client-toolsv3.11.0-0cbc58b-linux-64bit.tar.gz [root@ip-172-31-34-124 ~]# ls -lrt total 55200 -rw-------. 1 root root 7466 Apr 22 2020 original-ks.cfg -rw-------. 1 root root 8180 Apr 22 2020 anaconda-ks.cfg -rw-r--r--. 1 root root 56507103 Dec 7 08:29 openshift-origin-client-toolsv3.11.0-0cbc58b-linux-64bit.tar.gz drwxr-xr-x. 2 root root 63 Mar 9 15:37 openshift-origin-client-toolsv3.11.0-0cbc58b-linux-64bit [root@ip-172-31-34-124 ~]#
15. Copy the “oc” and “kubectl” binary to the system path.
[root@ip-172-31-34-124 ~]# cd openshift-origin-client-tools-v3.11.0-0cbc58blinux-64bit [root@ip-172-31-34-124 ]# ls -lrt total 235092 -rwxrwxr-x. 1 root root 120350344 Oct 10 2018 oc -rwxrwxr-x. 1 root root 120350344 Oct 10 2018 kubectl -rw-rwxr--. 1 root root 15834 Oct 10 2018 README.md -rw-rwxr--. 1 root root 10759 Oct 10 2018 LICENSE [root@ip-172-31-34-124 ]# cp oc kubectl /usr/bin [root@ip-172-31-34-124 ]#
16. Check the oc version.
[root@ip-172-31-34-124 ~]# oc version oc v3.11.0+0cbc58b kubernetes v1.11.0+d4cacc0 features: Basic-Auth GSSAPI Kerberos SPNEGO [root@ip-172-31-34-124 ~]#
OKD Cluster Setup
17. To start the cluster, you need to identify the communication IP or public IP (if this host is spun up from the cloud). In my case, I will login to the AWS console and take the pubic IP of this system.
18. Use “oc cluster up –public-hostname-PUBLICIP” command to setup the cluster. Here is my complete okd 3.11 setup logs.
[root@ip-172-31-34-124 ~]# oc cluster up --public-hostname=3.22.112.154 Getting a Docker client ... Checking if image openshift/origin-control-plane:v3.11 is available ... Pulling image openshift/origin-control-plane:v3.11 E0309 15:47:11.525223 2790 helper.go:179] Reading docker config from / root/.docker/config.json failed: open /root/.docker/config.json: no such file or directory, will attempt to pull image docker.io/openshift/origin-controlplane:v3.11 anonymously Pulled 1/5 layers, 27% complete Pulled 2/5 layers, 45% complete Pulled 3/5 layers, 72% complete Pulled 4/5 layers, 86% complete Pulled 5/5 layers, 100% complete Extracting Image pull complete Pulling image openshift/origin-cli:v3.11 E0309 15:47:27.118171 2790 helper.go:179] Reading docker config from / root/.docker/config.json failed: open /root/.docker/config.json: no such file or directory, will attempt to pull image docker.io/openshift/origin-cli:v3.11 anonymously Image pull complete Pulling image openshift/origin-node:v3.11 E0309 15:47:27.588634 2790 helper.go:179] Reading docker config from / root/.docker/config.json failed: open /root/.docker/config.json: no such file or directory, will attempt to pull image docker.io/openshift/originnode:v3.11 anonymously Pulled 5/6 layers, 95% complete Pulled 6/6 layers, 100% complete Extracting Image pull complete Checking type of volume mount ... Determining server IP ... Using public hostname IP 3.22.112.154 as the host IP Checking if OpenShift is already running ... Checking for supported Docker version (=>1.22) ... Checking if insecured registry is configured properly in Docker ... Checking if required ports are available ... Checking if OpenShift client is configured properly ... Checking if image openshift/origin-control-plane:v3.11 is available ... Starting OpenShift using openshift/origin-control-plane:v3.11 ... I0309 15:47:43.593621 2790 config.go:40] Running "create-master-config" I0309 15:47:45.571933 2790 config.go:46] Running "create-node-config" I0309 15:47:47.045397 2790 flags.go:30] Running "create-kubelet-flags" I0309 15:47:47.578532 2790 run_kubelet.go:49] Running "start-kubelet" I0309 15:47:47.744327 2790 run_self_hosted.go:181] Waiting for the kubeapiserver to be ready ... I0309 15:48:15.759975 2790 interface.go:26] Installing "kube-proxy" ... I0309 15:48:15.760544 2790 interface.go:26] Installing "kube-dns" ... I0309 15:48:15.760556 2790 interface.go:26] Installing "openshift-servicecert-signer-operator" ... I0309 15:48:15.760565 2790 interface.go:26] Installing "openshiftapiserver" ... I0309 15:48:15.760613 2790 apply_template.go:81] Installing "kube-proxy" I0309 15:48:15.760626 2790 apply_template.go:81] Installing "openshiftapiserver" I0309 15:48:15.760919 2790 apply_template.go:81] Installing "kube-dns" I0309 15:48:15.760983 2790 apply_template.go:81] Installing "openshiftservice-cert-signer-operator" I0309 15:48:18.282437 2790 interface.go:41] Finished installing "kubeproxy" "kube-dns" "openshift-service-cert-signer-operator" "openshiftapiserver" I0309 15:50:45.313435 2790 run_self_hosted.go:242] openshift-apiserver available I0309 15:50:45.313782 2790 interface.go:26] Installing "openshiftcontroller-manager" ... I0309 15:50:45.313803 2790 apply_template.go:81] Installing "openshiftcontroller-manager" I0309 15:50:47.370382 2790 interface.go:41] Finished installing "openshift-controller-manager" Adding default OAuthClient redirect URIs ... Adding router ... Adding persistent-volumes ... Adding web-console ... Adding centos-imagestreams ... Adding registry ... Adding sample-templates ... I0309 15:50:47.387828 2790 interface.go:26] Installing "openshiftrouter" ... I0309 15:50:47.387854 2790 interface.go:26] Installing "persistentvolumes" ... I0309 15:50:47.387866 2790 interface.go:26] Installing "openshift-webconsole-operator" ... I0309 15:50:47.387875 2790 interface.go:26] Installing "centosimagestreams" ... I0309 15:50:47.387885 2790 interface.go:26] Installing "openshift-imageregistry" I0309 15:50:47.389225 2790 apply_list.go:67] Installing "sample-templates/ dancer quickstart" I0309 15:50:47.389235 2790 apply_list.go:67] Installing "sample-templates/ postgresql" I0309 15:50:52.597129 2790 interface.go:41] Finished installing "sampletemplates/mariadb" "sample-templates/mysql" "sample-templates/postgresql" "sample-templates/dancer quickstart" "sample-templates/nodejs quickstart" "sample-templates/rails quickstart" "sample-templates/sample pipeline" "sample-templates/mongodb" "sample-templates/cakephp quickstart" "sampletemplates/django quickstart" "sample-templates/jenkins pipeline ephemeral" I0309 15:51:26.410759 2790 interface.go:41] Finished installing "openshift-router" "persistent-volumes" "openshift-web-console-operator" "centos-imagestreams" "openshift-image-registry" "sample-templates" Login to server ... Creating initial project "myproject" ... Server Information ... OpenShift server started. The server is accessible via web console at: https://3.22.112.154:8443/console You are logged in as: User: developer Password: <any value> To login as administrator: oc login -u system:admin [root@ip-172-31-34-124 ~]#
19. Check the cluster status.
[root@ip-172-31-34-124 ~]# oc status In project My Project (myproject) on server https://3.22.112.154:8443 You have no services, deployment configs, or build configs. Run 'oc new-app' to create an application. [root@ip-172-31-34-124 ~]#
20. You can login to OKD cluster .
[root@ip-172-31-34-124 ~]# oc login -u system:admin Logged into "https://3.22.112.154:8443" as "system:admin" using existing credentials. You have access to the following projects and can switch between them with 'oc project <projectname>': default kube-dns kube-proxy kube-public kube-system * myproject openshift openshift-apiserver openshift-controller-manager openshift-core-operators openshift-infra openshift-node openshift-service-cert-signer openshift-web-console Using project "myproject". [root@ip-172-31-34-124 ~]#
Accessing Openshift Web Console
21. To find the OKD cluster web URL, use the following command.
root@ip-172-31-34-124 ~]# oc cluster status Web console URL: https://3.22.112.154:8443/console/ Config is at host directory Volumes are at host directory Persistent volumes are at host directory /root/openshift.local.clusterup/ openshift.local.pv Data will be discarded when cluster is destroyed [root@ip-172-31-34-124 ~]#
22. Here is the web console.
Cloud Instance public IP got changed ?
In cloud, once you stop the instance and when you boot the instance later, It will come up with new public IP. If you use elastic IP, there will charges as well. To tackle this , you need to reset the cluster by following the below steps everytime when you boot up the system.
1.Login to the system as root user. Verify your “oc status” command output to know the cluster persistent volume host path.
root@ip-172-31-34-124 ~]# mv openshift.local.clusterup openshift.local.clusterup.old_ip
2. Start the cluster using the new public IP.
root@ip-172-31-34-124 ~]# oc cluster up --public-hostname=<System_Public_IP_Address>
3. Check the cluster status using “oc status” command.
4. You can find the logs in the /root/openshift.local.clusterup/logs directory for troubleshooting.
Hope this article is informative to you. If this article is informative, please share it with your professiotnal network.