Installation of Production Grade Kubernetes Cluster with KOPS

Installation of Production Grade Kubernetes Cluster with KOPS

Kubernetes Operations (kops) on Amazon Web Services (AWS)

Installing a production-grade Kubernetes cluster using Kubernetes Operations (kops) on Amazon Web Services (AWS) involves several steps. Below is a structured guide to help you through the process.

Prerequisites

AWS Account: Ensure you have an active AWS account.

AWS CLI: Install the AWS Command Line Interface (CLI) and configure it with your credentials.

Installation instructions can be found here.

Configure it using: aws configure

root@DevOps:—# aws configure 
AWS Access Key ID [****************W4M5]: 
AWS Secret Access Key [****************jtII]:

kubectl: Install kubectl, the Kubernetes command-line tool.

Installation instructions can be found here.

kops: Install kops, the Kubernetes Operations tool.

Installation instructions can be found here.

Resources Required

IAM Permissions: Ensure your AWS user has permissions to create and manage EC2 instances, VPCs, IAM roles, and Route 53 records.

S3 Bucket: Kops uses an S3 bucket to store the cluster state. You will need to create one.

Step-by-Step Instructions

Step 1: Create an S3 Bucket

    1. Log in to the AWS Management Console.

      1. Navigate to the S3 service.

      2. Click on "Create bucket".

      3. Enter a unique bucket name (e.g.,my-k8s-kops).

      4. Enable public access for this bucket and enable the checkmark on “I acknowledge”.

      5. Enable Bucket Versioning.

      6. Choose a region and configure other settings as needed.

      7. Click "Create bucket".

Step 2: Set Up Your Domain

    1. If you use “xxx.xx.local”, we don’t need to use Route 53. If using Route 53, we need a domain name and we need to create a hosted zone for your domain.

      1. Note the nameservers provided by Route 53.

Step 3: Create a Kubernetes Cluster Configuration

Step 4: Create the Cluster

    1. Use kops to create the cluster configuration:

      1. kops create cluster --name ${KOPS_CLUSTER_NAME} --state ${KOPS_STATE_STORE} --zones us-east-1a --node-count 2 --node-size t2.medium --master-size t2.medium --dns-zone example.com

Replace us-east-1a and example.com with your desired availability zone and domain.

Step 5: Edit the Cluster Configuration (Optional)

    1. You can edit the cluster configuration if needed:

      1. kops edit cluster --name ${KOPS_CLUSTER_NAME} --state ${KOPS_STATE_STORE}

Step 6: Validate the Cluster Configuration

    1. Validate the configuration to ensure everything is set up correctly:

      1. kops validate cluster --name ${KOPS_CLUSTER_NAME} --state ${KOPS_STATE_STORE}

Step 7: Create the Cluster

    1. Once validated, create the cluster:

      1. kops update cluster --name ${KOPS_CLUSTER_NAME} --state ${KOPS_STATE_STORE} --yes

        root@DevOps:—# kops update cluster --name kops.k8s.local --yes 
        *******************************************************************************
        A new kops version is available: 1.30.3 
        Upgrading is recommended More information: https://github.com/kubernetes/kops/blob/master/permalinks/upgrade kops.md#1.30.3
        ************************************************
        5804 apply cluster.go:545] Gossip DNS: skipping DNS validation 
        5804 executor.go:103] Tasks: 0 done / 92 total; 42 can run
        5804 vfs castore.go:590] Issuing new certificate: "etcd-clients-ca"
        5804 vfs castore.go:590] Issuing new certificate: "etcd-manager-ca-events"
        5804 vfs castore.go:590] Issuing new certificate: "etcd-manager-ca-main"
        5804 vfs castore.go:590] Issuing new certificate: "etcd-peers-ca-events"
        5804 vfs castore.go:590] Issuing new certificate: "ca"
        5804 vfs castore.go:590] Issuing new certificate: "etcd-peers-ca-main"
        5804 vfs castore.go:590] Issuing new certificate: "apiserver-aggregator-ca"
        

Step 8: Configure kubectl

    1. After the cluster is created, configure kubectl to use the new cluster:

      1. kops export kubecfg --name ${KOPS_CLUSTER_NAME} --state ${KOPS_STATE_STORE}

Step 9: Verify the Cluster

    1. Check the status of your nodes:

      1. kubectl get nodes

Conclusion

You have successfully installed a production-grade Kubernetes cluster using kops on AWS. For further management and scaling of your cluster, refer to the official kops documentation.