Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel

You can setup a Kubernetes cluster using one of the following approaches:

Expand
titleClick here to instructions...
Localtabgroup
Note

When working in a productions environment, setup the Kubernetes cluster based on your environment requirements. For more information, see the Kubernetes documentation.

Localtab
activetrue
titleKubernetes on Vagrant

Table of Contents
maxLevel3
minLevel3

Prerequisites 

Before starting, download and install the following prerequisites:

Follow the instructions below to setup Kubernetes with Vagrant:

  1. Clone the following Vagrant Git repository. This folder is referred to as <VAGRANT_KUBERNETES_SETUP>.

    Code Block
    git clone https://github.com/imesh/kubernetes-vagrant-setup.git
  2. Disable DHCP server in VirtualBox:

    Code Block
    VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
  3. Start a new Kubernetes cluster using the following command, which will start one master node and one minion:

    Code Block
    run.sh

     

    1. If more than one minion is needed, run the following command with the required number of instances. The number of instances you require is defined by n.

      Code Block
      run.sh NUM_INSTANCES=2
    2. If you need to specify the minion's memory and CPU, use the following command:
      Example: 

      Code Block
      run.sh NUM_INSTANCES=2 NODE_MEM=4096 NODE_CPUS=2
  4. Once the nodes are connected to the cluster and the state of the nodes are changed to Ready, the Kubernetes cluster is ready for use.
    Execute the following Kubernetes CLI commands and verify the cluster status:

    Code Block
    kubectl get nodes
    
    NAME           LABELS                                STATUS
    172.17.8.102   kubernetes.io/hostname=172.17.8.102   Ready
Info

Access the Kubernetes UI using the following URL http://<HOST>:<HTTP_PORT>/ui

Example: http://172.17.8.101:8080/ui

Tip

If you get a notification mentioning that the \"kube-ui\" endpoints cannot be found, execute the kube-ui-pod.sh script.

Localtab
titleKubernetes on EC2

Follow the instructions below to create an elastic Kubernetes cluster with three worker nodes and a master on a Mac Operating System, which is running in EC2:

Info

The Kubernetes cluster will also include the following sections:

 

  1. Install and configure Kubectl.

    Info
    iconfalse

    Kubectl is a client command line tool provided by the Kubernetes team. It helps monitor and manage Kubernetes Clusters.

    Code Block
    wget https://storage.googleapis.com/kubernetes-release/release/v1.0.1/bin/linux/amd64/kubectl
    chmod +x kubectl
    mv kubectl /usr/local/bin/

    For more information, see installing and configuring Kubectl.

  2. Install and configure the AWS Command Line Interface.

    Code Block
    wget https://bootstrap.pypa.io/get-pip.py
    sudo python get-pip.py
    sudo pip install awscli

    If you encounter an issue, use the following command to resolve it:

    Code Block
    sudo pip uninstall six
    sudo pip install --upgrade python-heatclient

    For more information see, AWS command line interface.

  3. Create the Kubernetes Security Group.

    Code Block
    aws ec2 create-security-group --group-name kubernetes --description "Kubernetes Security Group"
    aws ec2 authorize-security-group-ingress --group-name kubernetes --protocol tcp --port 22 --cidr 0.0.0.0/0
    aws ec2 authorize-security-group-ingress --group-name kubernetes --protocol tcp --port 80 --cidr 0.0.0.0/0
    aws ec2 authorize-security-group-ingress --group-name kubernetes --protocol tcp -p 30000-32767 --cidr 0.0.0.0/0
    aws ec2 authorize-security-group-ingress --group-name kubernetes --source-security-group-name kubernetes
    Note

    The port 8080 is not fixed. It will change based on the KUBERNETES_MASTER_PORT value you define in the Kubernetes Cluster resource definition.

    You can configure the KUBERNETES_MASTER_PORT by defining it under the Kubernetes Master property parameter.

    Example:

    Code Block
    {
      "name": "KUBERNETES_MASTER_PORT",
      "value": "8080"
    }
  4. Configure and save the master cloud-configs file. For more information, see the configuration details for master.yaml .
  5. Configure and save the node cloud-configs. For more information, see the configuration details for node.yaml .
  6. Launch the master.

    Note

    Replace the <ami_image_id> with a suitable version of the CoreOS image for AWS. It is recommend to use the following CoreOS alpha channel AMI Image ID: ami-f7a5fec7

    1. Run the instance.

      Code Block
      aws ec2 run-instances --image-id <ami_image_id> --key-name <keypair> \
      --region us-west-2 --security-groups kubernetes --instance-type m3.medium \
      --user-data file://master.yaml
    2. Record the InstanceId of the master.
    3. Gather the public and private IP ranges of the master node:

      Code Block
      aws ec2 describe-instances --instance-id <instance-id>

      The output:

      Code Block
      "Reservations": [
        {
          "Instances": [
            {
              "PublicDnsName": "ec2-54-68-97-117.us-west-2.compute.amazonaws.com",
              "RootDeviceType": "ebs",
              "State": {
                "Code": 16,
                "Name": "running"
              },
              "PublicIpAddress": "54.68.97.117",
              "PrivateIpAddress": "172.31.9.9",
              }
  7. Update the node.yaml cloud-config file.

    Replace all instances of the <master-private-ip> in the node.yaml file with the private IP address of the master node.

  8. Launch the three worker nodes.

    Note

    Replace the <ami_image_id> with a suitable version of the CoreOS image, for AWS. It is recommend to use the same AMI image ID used by the master.

    Code Block
    aws ec2 run-instances --count 3 --image-id <ami_image_id> --key-name <keypair> \
    --region us-west-2 --security-groups kubernetes --instance-type m3.medium \
    --user-data file://node.yaml
  9. Configure the Kubectl SSH tunnel.

    Info
    iconfalse

    This command enables a secure communication between the Kubectl client and the Kubernetes API.

    Code Block
    ssh -i key-file -f -nNT -L 8080:127.0.0.1:8080 core@<master-public-ip>
  10. List the worker nodes.

    Info
    iconfalse

    Once the worker instances are fully booted, the kube-register service running on the master node will automatically register the Kubernetes API server. This process will take several minutes.

    Code Block
    kubectl get nodes

...