• 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

How to Create Kubernetes Resources from Files or Stdin

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

The kubectl create command in Kubernetes is used to create resources based on the configuration provided either from files or directly from stdin. This command is essential for deploying applications and managing the infrastructure in Kubernetes clusters efficiently.

Here are several examples demonstrating how to use kubectl create with different Kubernetes resource configurations:

Example 1: Creating a Pod from a YAML file
Suppose you have a YAML file named pod.yaml describing a Kubernetes Pod. You can create this Pod using:

        kubectl create -f pod.yaml
    

To verify if the Pod has been created, you can check its status using:

        kubectl get pods
    

Example 2: Creating a Deployment from stdin
You can directly create a Deployment without using a file by passing the configuration via stdin:

        cat <

Verify the Deployment creation by checking its status:

        kubectl get deployments
    

Example 3: Creating a Service using imperative command
You can create a Kubernetes Service imperatively without using a file:

        kubectl create service clusterip my-service --tcp=80:8080
    

Verify the Service creation:

        kubectl get services
    

Example 4: Creating a ConfigMap from YAML
Create a ConfigMap using a YAML file:

        kubectl create -f configmap.yaml
    

Verify the ConfigMap creation:

        kubectl get configmap
    

Example 5: Creating a Secret from a literal value
You can create a Secret by passing literal values directly:

        kubectl create secret generic my-secret --from-literal=username=admin --from-literal=password=secretpassword
    

Verify the Secret creation:

        kubectl get secrets
    

Example 6: Creating a Namespace
Create a new Kubernetes Namespace:

        kubectl create namespace my-namespace
    

Verify the Namespace creation:

        kubectl get namespaces
    

Example 7: Creating a PersistentVolumeClaim
Create a PersistentVolumeClaim (PVC) from a YAML file:

        kubectl create -f pvc.yaml
    

Verify the PVC creation:

        kubectl get pvc
    

Example 8: Creating a Job from YAML
Create a Kubernetes Job using a YAML file:

        kubectl create -f job.yaml
    

Verify the Job creation:

        kubectl get jobs
    

Example 9: Creating a CronJob from YAML
Create a CronJob in Kubernetes from a YAML file:

        kubectl create -f cronjob.yaml
    

Verify the CronJob creation:

        kubectl get cronjobs
    

Example 10: Creating a HorizontalPodAutoscaler
Create a HorizontalPodAutoscaler (HPA) using a YAML file:

        kubectl create -f hpa.yaml
    

Verify the HPA creation:

        kubectl get hpa
    

Also check similar articles.

Overriding --databases Option in mysqldump
Creating Tab-Separated Output Files with mysqldump
Handling Failed SSL Session Data Reuse in mysqldump
Setting SSL Session Data File in mysqldump
Setting TLS 1.3 Cipher in mysqldump

Tags: KubernetesKubernetes Commands ExamplesKubernetes Commands TutorialKubernetes Tutorial
Previous Post

Overriding –databases Option in mysqldump

Next Post

Expose Kubernetes Services Easily with kubectl expose

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

Expose Kubernetes Services Easily with kubectl expose

howto

Running Docker Images on Kubernetes with kubectl run

howto

Setting Features on Kubernetes Objects using kubectl set

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.