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!π»
Top comments (0)