- In kubernetes,
Namespaces
are used to createisolated environments
for resources. Each Namespace is like aseparate cluster
within thesame physical cluster
.
Four Namespaces already in Kubernetes (Predefined)
:
default
- Kubernetes includes this namespace so that you can start using your new cluster without first creating a namespace.
kube-node-lease
- This namespace holds Lease objects associated with each node. Node leases allow the kubelet to send heartbeats so that the control plane can detect node failure.
kube-public
- This namespace is readable by all clients (including those not authenticated). This namespace is mostly reserved for cluster usage, in case that some resources should be visible and readable publicly throughout the whole cluster. The public aspect of this namespace is only a convention, not a requirement.
kube-system
- The namespace for objects created by the Kubernetes system.
How to check namespaces in kubernetes cluster ?
kubectl get namespace
- To create a Namespace use the command
kubectl create namespace <namespace-name>
- Apply the updated deployment using the command:
kubectl apply -f deployment.yml -n <namespace-name>
Also, verified by using command:
kubectl get namespace
Services
are used to expose yourPods
andDeployments
to thenetwork
.
- Types of services :
ClusterIP
,NodePort
,LoadBalancer
, andExternalName
.
ClusterIP
- ClusterIP is the default type of service, which is used to expose a service on an IP address internal to the cluster.
- Access is only permitted from within the cluster.
NodePort
- NodePorts are open ports on every
cluster node
. Kubernetes willroute traffic
that comes into aNodePort
to the service, even if the service is not running on that node. - NodePort is intended as a foundation for other
higher-level methods of ingress
such asload balancers
and are useful in development.
LoadBalancer
- For clusters running on public cloud providers like AWS or Azure, creating a load LoadBalancer service provides an equivalent to a clusterIP service, extending it to an external load balancer that is specific to the cloud provider.
- Kubernetes will automatically create the load balancer, provide firewall rules if needed, and populate the service with the external IP address assigned by the cloud provider.
ExternalName
ExternalName
services are similar to other Kubernetes services; however, instead of being accessed via aclusterIP address
, it returns aCNAME record
with a value that is defined in the externalName: parameter when creating the service.