Bite-Sized Kubernetes Part 6 - Ingress, Volumes, Namespaces & Clusters

the777ist

Hrittik Bhattacharjee

Posted on March 9, 2023

Bite-Sized Kubernetes Part 6 - Ingress, Volumes, Namespaces & Clusters

Land Ahoy!☸️

You made it! Land in sight!🏝️
In the last part we learnt about services in kubernetes.
In this final part of the series, we shall be exploring Ingress, Volumes and Namespaces! We shall also briefly revisit Clusters since you already learnt what they are in Part 1!

OBJECT DESCRIPTION
Pods The lowest level, single instance of an application
ReplicaSets The next level, manages a set of pods
Deployments The next level, manages a set of ReplicaSets
Services The next level, manages a set of deployments
πŸ‘‰ Ingress The next level, manages a set of services
πŸ‘‰ Volumes The next level, manages a set of ingress
πŸ‘‰ Namespaces The next level, manages a set of volumes
πŸ‘‰ Cluster The highest level, manages a set of namespaces

Ingress:

  • Ingress is a set of rules that allow external traffic to reach the cluster services.
  • Creating ingress:

    • Example ingress-definition.yml:

      apiVersion: extensions/v1beta1
      kind: Ingress
      metadata:
        name: my-app-ingress
      spec:
        rules:
          - host: myapp.com
            http:
              paths:
                - path: /
                  backend:
                    serviceName: my-app-service
                    servicePort: 80
      
    • The host property is the domain name that the ingress will listen for requests on.

    • The path property is the path that the ingress will listen for requests on.

    • The serviceName property is the name of the service that the ingress will forward requests to.

    • The servicePort property is the port on the service that the ingress will forward requests to.

    • Once the .yml file is created, it can be used to create an ingress:

      $ kubectl create -f <file name>.yml
      
    • See list of ingresses:

      $ kubectl get ingresses
      
    • See detailed info about an ingress:

      $ kubectl describe ingress <ingress name>
      
    • To access the ingress from outside the cluster, use the node IP address and the node port:

      $ curl <node IP address>:<node port>
      
    • To access the ingress from inside the cluster, use the cluster IP address and the port:

      $ curl <cluster IP address>:<port>
      

Volumes:

  • Volumes are used to store data that is not ephemeral.
  • Volumes are created in the cluster and are mounted to the pods.
  • Types of volumes:
    • EmptyDir: a temporary volume that is created when a pod is created and is deleted when the pod is deleted.
    • HostPath: a volume that is mounted from the host machine to the pod.
    • PersistentVolume: a volume that is created in the cluster and is mounted to the pods.
    • PersistentVolumeClaim: a claim for a persistent volume.
  • Creating a volume:

    • Example volume-definition.yml:

      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: my-app-volume
      spec:
        capacity:
          storage: 1Gi
        accessModes:
          - ReadWriteOnce
        hostPath:
          path: /data/my-app
      
    • The capacity property is the size of the volume.

    • The accessModes property is the access mode of the volume.

    • The hostPath property is the path on the host machine where the volume will be created.

    • Once the .yml file is created, it can be used to create a volume:

      $ kubectl create -f <file name>.yml
      
    • See list of volumes:

      $ kubectl get pv
      
    • See detailed info about a volume:

      $ kubectl describe pv <volume name>
      

Namespaces:

  • Namespaces are used to isolate resources in the cluster.
  • Namespaces are created in the cluster and are used to group resources.
  • Creating a namespace:

    • Example namespace-definition.yml:

      apiVersion: v1
      kind: Namespace
      metadata:
        name: my-app-namespace
      
    • Once the .yml file is created, it can be used to create a namespace:

      $ kubectl create -f <file name>.yml
      
    • See list of namespaces:

      $ kubectl get namespaces
      
    • See detailed info about a namespace:

      $ kubectl describe namespace <namespace name>
      

Clusters:

  • We have already understood clusters at the very beginning of this blog series.
  • A cluster is just a set of nodes (machines) that run containerized applications i.e. k8s pods.
  • A cluster can be created using a cloud provider or using a single node.
  • Try creating cluster and playing around with it on your local machine using minikube or kubeadm or you can get started with the services offered by cloud providers like AWS (EKS), GCP (GKE) or Azure (AKS).

Well done and hearty congratulations Sailor!!!πŸ₯πŸ“―
You are hereby commissioned Ensign and are now ready to join the fleet!πŸŽ–οΈπŸŽ–οΈπŸŽ–οΈ
To be an explorer and a force for good! To venture out into the great sea!πŸŒ… To fight monsters πŸ¦‘ and explore uncharted lands!🏞️

Hope this series was fun!
Feel free to check the references below to take your journey of building with Kubernetes further ahead and put your newly acquired skills to the test!
Cheers and until next time!🍻

References:

πŸ’– πŸ’ͺ πŸ™… 🚩
the777ist
Hrittik Bhattacharjee

Posted on March 9, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related