My first path to Kubernetes setup in production — PART 2 of 2

My first path to Kubernetes setup in production — PART 2 of 2

Jothimani Radhakrishnan's photo
Jothimani Radhakrishnan
·Feb 19, 2019·

3 min read

Hey hi,

if you have missed out my previous blog on env setup in AWS for EKS cluster and worker nodes, please have a look at here. “[

Lets get move along with some deployments;

Before surfing in, lets learn some basics of k8s, commands and a simple what is what on all the naming conventions

K8s cluster: A cluster consists of at least one cluster master and multiple worker machines called nodes; This is fundamental blocks for Kubernetes.

K8s workers: Workers consists of at least one or more nodes (linux machines) which is also called as nodes. Each node holds the required services to run a pod.

K8s Pods: Pods are group of containers that are deployed for an application in a host machine. i.e pods aka container

Learn more on the k8s doc page:

Okay lets know some most useful commands and shortcuts of the same.

As we have configured kubectl in our cluster manager, all our commands will prefix kubectl.

This will list all the ungrouped/default namespaces running containers. (namespaces are used to group the deployments,services etc. We are not discussing in detail on the namespaces)

kubectl get pods aka kubectl get po

This will list all the ungrouped/default namespaces running services.

kubectl get services aka kubectl get svc

This will list all the ungrouped/default namespaces running nodes.

kubectl get nodes

This will list all the ungrouped/default namespaces running deployments.

kubectl get deployments aka kubectl get deploy

Lets start deploying a simple application and create a service and finally access them via load balancer.

  1. Creating deployments (jenkins-deployment.yaml)

save this as yaml file replacing the required fields which best suits your app; for the ease I have used jenkins image.

apiVersion: extensions/v1beta1
kind: Deployment
  app: jenkins
  replicas: 2
        app: jenkins
      - name: demo-jenkins
        image: jenkins:2.3-alpine
          - containerPort: 8080

to deploy the app;

kubectl deploy -f jenkins-deployment.yaml

Decoding the above yaml file:

  • kind states it is deployment with added tags.

  • specs: we need two replicas (i.e, containers) and req labels:

  • Then container definition: name of the container and image repository and followed by the container port to expose.

To check the success deployment:

kubectl get deploy

kubectl get pods — This will display the status of the pods/containers

your jenkins-deployment status will be displayed

  1. Creating a service (jenkins-service.yaml)
kind: Service
apiVersion: v1
  name: jenkins-deployment
    app: jenkins
  - protocol: TCP
    port: 80
    targetPort: 8080
  type: LoadBalancer

The above script will expose the deployed app under port 80 and map it with the pods running under 8080, using a load balancer (cloud native) in our case an elastic load balancer (classic)was created in the region.

we can also use multiple port exposure, ALB and ingress controller and many more…we will discuss those in upcoming blogs

kubectl apply -f jenkins-service.yaml

get the status of the service using jenkins-service.

kubectl get svc jenkins-deployment — This will list the status of the service

  1. Accessing the service from the load balancer address.

kubectl get svc jenkins-deployemnt

the above command will display the k8s svc status with external DNS name (load balancer cname)

Copy and paste the load balancer dns in web browser;

bingo! we have our app ready.

We can also deploy the app with multiple ports exposed and we can use application load balancers as well; sounds interesting? Let’s discuss more in the next blog.

Thank you! :)

Did you find this article valuable?

Support Jothimani Radhakrishnan by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
Share this