• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Kubernetes

Applying Kubernetes Configurations with kubectl apply

June 26, 2024
in Kubernetes, Kubernetes Commands Examples, Kubernetes Commands Tutorial, Kubernetes Tutorial
A A
0
11
SHARES
103
VIEWS
Share on FacebookShare on Twitter

Using kubectl apply allows Kubernetes configurations to be applied or updated based on the YAML or JSON files provided. This command is essential for deploying new resources, updating existing configurations, or even reverting to a previous state if needed.

Here are several examples showcasing the versatility of kubectl apply:

Example 1: Deploying a new Pod from a YAML file:

kubectl apply -f pod.yaml

This command applies the Pod configuration defined in pod.yaml. To verify, use kubectl get pods to see if the Pod is running.

Example 2: Updating a Deployment with a new image:

kubectl apply -f deployment.yaml

If deployment.yaml specifies a new Docker image, this command updates the Deployment accordingly. Check the Deployment status with kubectl get deployment.

Example 3: Applying a Service definition:

kubectl apply -f service.yaml

Creates or updates a Kubernetes Service based on the configuration in service.yaml. Confirm the Service’s creation with kubectl get services.

Example 4: Adding a ConfigMap to the cluster:

kubectl apply -f configmap.yaml

This applies the ConfigMap defined in configmap.yaml. Verify its existence with kubectl get configmap.

Example 5: Applying a PersistentVolumeClaim:

kubectl apply -f pvc.yaml

Creates or updates a PersistentVolumeClaim as defined in pvc.yaml. Check its status using kubectl get pvc.

Example 6: Deploying a CronJob:

kubectl apply -f cronjob.yaml

This command schedules a new CronJob based on the configuration provided in cronjob.yaml. Use kubectl get cronjob to see its execution status.

Example 7: Applying a HorizontalPodAutoscaler:

kubectl apply -f hpa.yaml

Creates or updates a HorizontalPodAutoscaler defined in hpa.yaml. Verify its creation using kubectl get hpa.

Example 8: Deploying a StatefulSet:

kubectl apply -f statefulset.yaml

Applies the StatefulSet configuration from statefulset.yaml. Check its deployment status with kubectl get statefulset.

Example 9: Updating a Namespace:

kubectl apply -f namespace.yaml

If namespace.yaml modifies Namespace attributes, this command updates it. Ensure changes with kubectl get namespace.

Example 10: Applying a Role and RoleBinding:

kubectl apply -f role.yaml -f rolebinding.yaml

Applies both Role and RoleBinding configurations defined in respective files. Verify creation with kubectl get roles and kubectl get rolebindings.

Also check similar articles.

Diffing Kubernetes Configurations with kubectl diff
Listing Kubernetes Events with kubectl events
Troubleshooting Kubernetes with kubectl debug
Managing Kubernetes Authorization with kubectl auth
Copy Files to and from Kubernetes Containers with kubectl cp

Tags: KubernetesKubernetes Commands ExamplesKubernetes Commands TutorialKubernetes Tutorial
Previous Post

Diffing Kubernetes Configurations with kubectl diff

Next Post

Patching Kubernetes Resources with kubectl patch

Related You may like!

howto

Interacting with Kubernetes Plugins using kubectl plugin

June 26, 2024
howto

Configuring kubectl and kubeconfig Files

June 26, 2024

Exploring Kubernetes API Versions with kubectl api-versions

June 26, 2024

Understanding Kubernetes API Resources with kubectl api-resources

June 26, 2024

Generating Shell Completion Code with kubectl completion

June 26, 2024

Managing Kubernetes Annotations with kubectl annotate

June 26, 2024
Next Post
howto

Patching Kubernetes Resources with kubectl patch

howto

Replace Kubernetes Resources with kubectl replace

howto

Waiting for Kubernetes Resources with kubectl wait

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Dumping BLOBs in Hexadecimal Format with mysqldump

    16 shares
    Share 6 Tweet 4
  • How to Exclude Bad Names when Creating User Accounts in Linux

    14 shares
    Share 6 Tweet 4
  • Using BTRFS Subvolume for User Home Directory in Linux

    24 shares
    Share 10 Tweet 6
  • Managing Kubernetes Certificates with kubectl certificate

    20 shares
    Share 8 Tweet 5
  • Running Docker Images on Kubernetes with kubectl run

    13 shares
    Share 5 Tweet 3
  • Disabling Keys in mysqldump Output

    12 shares
    Share 5 Tweet 3
  • Managing Docker Image Manifests and Lists

    12 shares
    Share 5 Tweet 3
  • Adding Dump Date to mysqldump Output

    11 shares
    Share 4 Tweet 3
  • Updating Kubernetes Labels with kubectl label

    12 shares
    Share 5 Tweet 3
  • Sorting Rows by Primary Key in mysqldump Output

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.