Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Kubernetes - A Complete DevOps Cookbook

You're reading from   Kubernetes - A Complete DevOps Cookbook Build and manage your applications, orchestrate containers, and deploy cloud-native services

Arrow left icon
Product type Paperback
Published in Mar 2020
Publisher Packt
ISBN-13 9781838828042
Length 584 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Murat Karslioglu Murat Karslioglu
Author Profile Icon Murat Karslioglu
Murat Karslioglu
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Building Production-Ready Kubernetes Clusters 2. Operating Applications on Kubernetes FREE CHAPTER 3. Building CI/CD Pipelines 4. Automating Tests in DevOps 5. Preparing for Stateful Workloads 6. Disaster Recovery and Backup 7. Scaling and Upgrading Applications 8. Observability and Monitoring on Kubernetes 9. Securing Applications and Clusters 10. Logging with Kubernetes 11. Other Books You May Enjoy

Configuring Red Hat OpenShift

In this recipe, we will learn how to deploy Red Hat OpenShift on AWS, bare-metal, or VMware vSphere VMs.

The steps in the Provisioning an OpenShift cluster recipe can be applied to deploy OpenShift on either VMs running on a virtualized environment or bare-metal servers.

Getting ready

All the operations mentioned here require a Red Hat account with active Red Hat Enterprise Linux and OpenShift Container Platform subscriptions. If you don't have one already, go to https://access.redhat.com and create an account.

When you deploy on VMs, make sure to plan that the zones you create on Kubernetes nodes are actually physically located on separate hypervisor nodes.

For this recipe, we need to have a minimum of six nodes with Red Hat Enterprise CoreOS installed on them. These nodes can be either bare-metal, VMs, or a mix of bare-metal and VMs.

How to do it…

This section will take you through how to configure Red Hat OpenShift. To that end, this section is further divided into the following subsections to make this process easier:

  • Downloading OpenShift binaries
  • Provisioning an OpenShift cluster
  • Connecting to OpenShift clusters

Downloading OpenShift binaries

Make sure you are on the Terminal of your first master and that you have an account with root access, or you are running as a superuser. Follow these steps:

  1. Go to https://cloud.redhat.com/openshift/install and download the latest OpenShift Installer:
  1. Extract the installer files on your workstation:
$ tar -xzf openshift-install-linux-*.tar.gz

The preceding command will create a file called openshift-install in the same folder.

Provisioning an OpenShift cluster

In this recipe, we will use the AWS platform to deploy OpenShift:

  1. To get your OpenShift cluster up, use the following command:
$ ./openshift-install create cluster
  1. Choose aws as your platform and enter your AWS Access Key ID and Secret Access Key.
  2. Choose your region. In our example, this is us-east-1.
  3. Select a base domain. In our example, this is k8s.containerized.me.
  4. Enter a cluster name.
  5. Copy Pull Secret from the Red Hat site and paste it onto the command line:
  1. After the installation is complete, you will see the console URL and credentials for accessing your new cluster, similar to the following:
INFO Install complete!
INFO To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=/home/ubuntu/auth/kubeconfig'
INFO Access the OpenShift web-console here: https://console-openshift-console.apps.os.k8s.containerized.me
INFO Login to the console with user: kubeadmin, password: ABCDE-ABCDE-ABCDE-ABCDE
  1. Switch to the Red Hat site and click on the Download Command-Line Tools link to download openshift-client.
  2. Extract the openshift-client files in your workstation:
$ tar -xzf openshift-client-linux-*.tar.gz && sudo mv oc /usr/local/bin

The preceding command will create the kubectl and oc files on the same folder and move the oc binary to PATH.

Connecting to OpenShift clusters

To connect to OpenShift clusters, follow these steps:

  1. To get access to your OpenShift cluster, use the following command:
$ export KUBECONFIG=~/auth/kubeconfig
  1. Log in to your OpenShift cluster after replacing password and cluster address:
$ oc login -u kubeadmin -p ABCDE-ABCDE-ABCDE-ABCDE \
https://api.openshift.k8s.containerized.me:6443 \
--insecure-skip-tls-verify=true

If you prefer to use the web console instead, open the web console URL address from the Provisioning an OpenShift cluster recipe, in step 7.

How it works…

This recipe showed you how to quickly deploy an OpenShift cluster on AWS.

In step 1, we created a cluster using the default configuration of the installer-provisioned infrastructure.

The installer asked a series of questions regarding user information and used mostly default values for other configuration options. These defaults can be edited and customized if needed using the install-config.yaml file.

To see the defaults that were used for the deployment, let's create an install-config.yaml file and view it:

$ ./openshift-install create install-config && cat install-config.yaml

As you can see from the following output, the file's default configuration creates a cluster consisting of three master and three worker nodes:

apiVersion: v1
baseDomain: k8s.containerized.me
compute:
- hyperthreading: Enabled
name: worker
platform: {}
replicas: 3
controlPlane:
hyperthreading: Enabled
name: master
platform: {}
replicas: 3
...

Edit install-config.yaml as needed. Next time you create the cluster, new parameters will be used instead.

There's more…

It is also useful to have knowledge of the following information:

  • Deleting your cluster

Deleting your cluster

To delete your cluster, use the following command:

$ ./openshift-install destroy cluster

This process will take a few minutes and, when finished, you will get a confirmation message.

See also

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image