• 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

Setting Features on Kubernetes Objects using kubectl set

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

Kubernetes provides powerful management capabilities through its command-line tool kubectl. One of the key functionalities is set, which allows users to modify features on Kubernetes objects directly from the command line. This capability is particularly useful for adjusting configurations or settings dynamically without needing to edit YAML files manually.

Here are several examples demonstrating the use of kubectl set with different Kubernetes objects:

Example 1: Setting environment variables on a Deployment
kubectl set env deployment/my-deployment ENV_VAR=value
This command updates the environment variable ENV_VAR with the value value on the Deployment named my-deployment.

Verification: Verify the environment variable is set correctly by describing the Deployment and checking its environment section.

Example 2: Scaling replicas of a Deployment
kubectl scale deployment/my-deployment --replicas=3
This command adjusts the number of replicas of the Deployment named my-deployment to 3.

Verification: List the pods to ensure three instances of the Deployment are running.

Example 3: Adding a label to a Pod
kubectl label pod/my-pod new-label=example
This command adds a label new-label with the value example to the Pod named my-pod.

Verification: Describe the Pod and confirm the label has been applied.

Example 4: Setting a resource request on a Pod
kubectl set resources pod/my-pod --requests=cpu=200m,memory=512Mi
This command sets CPU request to 200 milliCPU and memory request to 512 MiB for the Pod named my-pod.

Verification: Get the Pod’s YAML definition to see the updated resource requests.

Example 5: Updating an annotation on a Service
kubectl annotate service/my-service description='New description'
This command updates the annotation description with the value New description on the Service named my-service.

Verification: Describe the Service to confirm the annotation has been updated.

Example 6: Setting a service account on a Pod
kubectl set serviceaccount pod/my-pod my-service-account
This command sets the service account my-service-account on the Pod named my-pod.

Verification: Describe the Pod and check its service account setting.

Example 7: Setting a command and arguments on a Pod
kubectl set command pod/my-pod -- ls -l
This command sets the command to ls and arguments to -l on the Pod named my-pod.

Verification: Get the Pod’s YAML definition to see the updated command and arguments.

Example 8: Setting a node selector on a Deployment
kubectl set selector deployment/my-deployment app=example-app
This command sets the node selector to match nodes labeled with app=example-app for the Deployment named my-deployment.

Verification: Describe the Deployment and verify the node selector configuration.

Example 9: Setting a priority class on a Pod
kubectl set priority pod/my-pod high-priority
This command sets the priority class to high-priority on the Pod named my-pod.

Verification: Describe the Pod and ensure the priority class is applied correctly.

Example 10: Setting a toleration on a Pod
kubectl set tolerations pod/my-pod key=value:NoSchedule
This command sets a toleration with key key, value value, and effect NoSchedule on the Pod named my-pod.

Verification: Describe the Pod and check the tolerations section to confirm the toleration is set.

Also check similar articles.

Running Docker Images on Kubernetes with kubectl run
Expose Kubernetes Services Easily with kubectl expose
How to Create Kubernetes Resources from Files or Stdin
Overriding –databases Option in mysqldump
Creating Tab-Separated Output Files with mysqldump

Tags: KubernetesKubernetes Commands ExamplesKubernetes Commands TutorialKubernetes Tutorial
Previous Post

Running Docker Images on Kubernetes with kubectl run

Next Post

Understanding Kubernetes Resources with kubectl explain

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

Understanding Kubernetes Resources with kubectl explain

howto

Comprehensive Guide to kubectl get Command

howto

Efficiently Delete Kubernetes Resources with kubectl delete

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

    Using BTRFS Subvolume for User Home Directory in Linux

    22 shares
    Share 9 Tweet 6
  • Downloading Docker Images from a Registry

    13 shares
    Share 5 Tweet 3
  • Configuring SSL Connection Mode in mysqldump

    17 shares
    Share 7 Tweet 4
  • Omit Tablespace Information in mysqldump Output

    13 shares
    Share 5 Tweet 3
  • Setting MySQL Dump Compatibility Mode

    18 shares
    Share 7 Tweet 5
  • Setting Network Buffer Length in mysqldump

    13 shares
    Share 5 Tweet 3
  • Logging out from Docker Registries

    13 shares
    Share 5 Tweet 3
  • Scheduling Nodes in Kubernetes with kubectl uncordon

    12 shares
    Share 5 Tweet 3
  • Managing Default User Creation Settings in Linux

    15 shares
    Share 6 Tweet 4
  • Using Extended INSERT Syntax in mysqldump

    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.