Object Name
Every Kubernetes
object has a Name that is unique for that type of resource within the
same namespace. It means, we can only have one Pod name called “mynginx”
within the same namespace. however, we can use same name for another Kubernetes
object like Deployment, Service, etc.
So, we can set same name i.e., “mynginx” to Pod, Deployment, Service, etc.
The following characteristics need to be followed while setting name to Kubernetes object.
- Name should not exceed 253 characters
- It contains only lowercase alphanumeric characters (a to z), hyphen (-), period(.)
- It should start with an alphanumeric character
- It should end with an alphanumeric character
Labels
Label is a
key-value pair which is attached to pods, deployments, etc.
- It acts an identifier on K8 object (Ex: Pod or Deployment). So, the other Kubernetes objects (Ex: Service, DaemonSet) can communicate by matching same label names.
- It can be attached to Kubernetes objects at creation time or directly on live objects by using Imperative way
- Same label key/value can be assigned to multiple Kubernetes objects
- Each object in the label can have set of key/value and each key must be unique for a given object
- Label key should not exceed 63 characters and allowed characters are alphanumeric, dash(-), underscore(_), dot(.)
- Label value should not exceed 63 characters and allowed characters are alphanumeric, dash(-), underscore(_), dot(.)
Example: Creating labels on Pod
Selector
It is used for grouping
Kubernetes objects and perform actions accordingly.
a) It is used by Kubernetes Deployment object to talk to all Pods with particular label key/value
b) It is used by Kubernetes Service object to expose all Pods with particular label key/value
Example: Adding labels on Pod template and Selector tag for identifying all Pod labels in the Deployment
Here, we have
added selector tag with matchLabels(app:nginx) used by deployment for
identifying all the Pods where label equal to app:nginx and apply Deployment
rules
Here, we have added selector tag used by Service for identifying all the Pods where label name equal to app:nginx and apply Service rules
Namespace
Kubernetes
supports multiple virtual clusters by using Namespaces. It helps when multiple
teams using same cluster and create separate Roles, Binding and Environments for
each team.
- Kubernetes resource name should be unique within a namespace, but not across namespaces
- Namespaces cannot be nested
- Each Kubernetes resource can only be in one namespace
- Don’t create namespace with prefix “kube-“. Because, it is reserved for K8 system
- By default, each resource created under “default” namespace
- Kubernetes for Developers #25: PersistentVolume and PersistentVolumeClaim in-detail
- Kubernetes for Developers #24: Kubernetes Volume hostPath in-detail
- Kubernetes for Developers #23: Kubernetes Volume emptyDir in-detail
- Kubernetes for Developers #22: Access to Multiple Clusters or Namespaces using kubectl and kubeconfig
- Kubernetes for Developers #21: Kubernetes Namespace in-detail
- Kubernetes for Developers #20: Create Automated Tasks using Jobs and CronJobs
- Kubernetes for Developers #19: Manage app credentials using Kubernetes Secrets
- Kubernetes for Developers #18: Manage app settings using Kubernetes ConfigMap
- Kubernetes for Developers #17: Expose service using Kubernetes Ingress
- Kubernetes for Developers #16: Kubernetes Service Types - ClusterIP, NodePort, LoadBalancer and ExternalName
- Kubernetes for Developers #15: Kubernetes Service YAML manifest in-detail
- Kubernetes for Developers #14: Kubernetes Deployment YAML manifest in-detail
- Kubernetes for Developers #13: Effective way of using K8 Readiness Probe
- Kubernetes for Developers #12: Effective way of using K8 Liveness Probe
- Kubernetes for Developers #11: Pod Organization using Labels
- Kubernetes for Developers #10: Kubernetes Pod YAML manifest in-detail
- Kubernetes for Developers #9: Kubernetes Pod Lifecycle
- Kubernetes for Developers #8: Kubernetes Object Name, Labels, Selectors and Namespace
- Kubernetes for Developers #7: Imperative vs. Declarative Kubernetes Objects
- Kubernetes for Developers #6: Kubernetes Objects
- Kubernetes for Developers #5: Kubernetes Web UI Dashboard
- Kubernetes for Developers #4: Enable kubectl bash autocompletion
- Kubernetes for Developers #3: kubectl CLI
- Kubernetes for Developers #2: Kubernetes for Local Development
- Kubernetes for Developers #1: Kubernetes Architecture and Features
Looks good. Could you please share how the IP address assigning new and re-create pods.
ReplyDelete