k8slearn-yaml-02

YAML Definition File for Kubernetes

Key Concepts in Kubernetes YAML Config Files:

apiVersion:

  • Type: String
  • Description: Specifies the API version for the Kubernetes object you’re creating. The correct API version depends on the kind of Kubernetes object you’re defining.
  • Example: apiVersion: v1

kind:

  • Type: String
  • Description: Indicates the type of Kubernetes object being created (e.g., Pod, Service, Deployment).
  • Example: kind: Pod

metadata:

  • Type: Dictionary
  • Description: Provides metadata about the Kubernetes object.
  • name: The name of the Kubernetes object (required).
  • Example: name: myapp-pod
  • labels: Key-value pairs used for grouping or selecting Kubernetes objects.
  • Example:
  • annotations: Key-value pairs for storing miscellaneous information that Kubernetes itself doesn’t use but could be utilized by other tools.
  • Example:

spec:

  • Type: Dictionary
  • Description: Defines the desired state of the Kubernetes object. The content here varies depending on the kind of object being created.
  • Example for a Pod:

Deployment Using kubectl

Command: To deploy the Kubernetes object defined in the YAML file, you use:

Overriding Dockerfile CMD and ENTRYPOINT in Kubernetes

Dockerfile Example:

YAML Example:

If you want to override the CMD or ENTRYPOINT defined in a Dockerfile when deploying a container in Kubernetes, you can specify them in the command and args fields in the YAML file.

In this example, the command field overrides the ENTRYPOINT in the Dockerfile, and the args field overrides the CMD. This ensures that when the container is deployed in Kubernetes, it runs with the desired command and arguments.

Leave a Reply

Your email address will not be published. Required fields are marked *