Install Docker and Kubernetes on Oracle Linux behind a proxy

Uday Chandra
Oracle Developers
Published in
3 min readNov 14, 2018
Photo by chuttersnap on Unsplash

This article walks you through the steps required to install and configure Docker and Kubernetes on a bare metal or virtual machine running Oracle Linux (OL) 7.x that’s behind a corporate proxy.

Prerequisites

Make sure you meet these prerequisites:

  • OL 7.x using Unbreakable Enterprise Kernel Release 4 (UEK R4) or later
  • yum is configured to talk to your corporate proxy. For quick reference, you can edit “/etc/yum.conf” and add or update the proxy entry:
proxy=http://<proxy-host>:<proxy-port>

Install Docker Engine

Edit “/etc/yum.repos.d/public-yum-ol7.repo” and enable the “ol7_addons” channel. It’s a matter of setting the “enabled” option to “1” under “ol7_addons” section. Next, run yum to install the latest docker engine that is made available on this channel:

yum install docker-engine

Configure Proxy

Create the file “/etc/systemd/system/docker.service.d/http-proxy.conf” and add the following:

[Service]
Environment="HTTP_PROXY=<proxy-host>:<proxy-port>"
Environment="HTTPS_PROXY=<proxy-host>:<proxy-port>"
Environment="NO_PROXY=localhost,127.0.0.1,<your-no-proxy-entries>"

Make sure to replace the “<proxy-host>”, “<proxy-port>” and “<your-no-proxy-entries>” with appropriate values for your environment.

Now run the following commands to start the docker engine and ensure that it starts back on reboots:

systemctl daemon-reload
systemctl enable docker
systemctl start docker

You can check the status and version of docker by running the following commands:

systemctl status docker
docker version

Using a web browser, login to Oracle Container Registry website at https://container-registry.oracle.com. Navigate to the Container Services category and accept the license agreement.

Install Kubernetes Master Node

Make sure the “ol7_addons” channel is enabled (refer to install docker engine section above). Run yum to install “kubeadm”:

yum install kubeadm

Now login to the Oracle Container registry using Docker CLI:

docker login container-registry.oracle.com/kubernetes

As root, run the following command to add sbin to the PATH variable:

export PATH=$PATH:/sbin

As root, run the following command to add a port forwarding rule:

iptables -P FORWARD ACCEPT

If you are running “firewalld” service, as root, run the following commands:

firewall-cmd --add-masquerade --permanent
firewall-cmd --add-port=10250/tcp --permanent
firewall-cmd --add-port=8472/udp --permanent
firewall-cmd --add-port=6443/tcp --permanent

And finally, as root, run this command to configure the host as a master node:

kubeadm-setup.sh up

If there are any issues, the above command will notify you with possible remedies. After a successful run, the command will print the next steps which boil down to preparing the regular user to run “kubectl” commands and the command to be run on other hosts which will act as worker nodes in the kubernetes cluster. Take a note of the token and hash that you will use later to join worker nodes to the cluster.

Install Kubernetes Worker Nodes

On each additional OL machine that should be provisioned as a worker node, repeat all the steps, except the last one, that you executed above while provisioning the master node.

Instead of running the last step from above, as root, run the kubeadm-setup join command:

kubeadm-setup.sh join --token <token> <master-host>:6443 \
--discovery-token-ca-cert-hash <hash>

After provisioning the worker nodes, you can go back to the master node and run the following command to get a glimpse of all the nodes:

kubectl get nodes

You are all set to start deploying services and play with Kubernetes.

Refer to the following links for additional information and in-depth documentation:

--

--