Stop coding manually! Found this amazing tool that generates K8S YAML in one click!

Stop coding manually! Found this amazing tool that generates K8S YAML in one click!

In daily K8S operation and maintenance work, we usually obtain YAML templates in the following two friendly ways:

  • I usually collect and organize various YAML template files by myself.
  • Temporarily generate the required YAML template file through a trial run. For example, you can generate a deployment YAML file using the following command.
 kubectl create deploy deploy-nginx -o yaml \ --port=80 --image=nginx --dry-run=client

After executing the above command, a deploy YAML file will be generated in the terminal, as shown below:

 apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: deploy-nginx name: deploy-nginx spec: replicas: 1 selector: matchLabels: app: deploy-nginx strategy: {} template: metadata: creationTimestamp: null labels: app: deploy-nginx spec: containers: - image: nginx name: nginx ports: - containerPort: 80 resources: {} status: {}

The above basic information has been generated. However, if you need to deploy to another namespace, you need to add the namespace yourself. Or add parameters to specify the namespace to deploy in the command line. The command is as follows:

 kubectl create deploy deploy-nginx -o yaml \ --port=80 --image=nginx \ --namespace=dev \ --dry-run=client

Plugin Installation

Today I will introduce a very useful tool that can generate a YAML template for K8S resources with one click. To use this tool, you need to prepare the following environment in advance:

Install Visual studio Code (version >= 1.38)

Install Red Hat YAML, a plugin that provides comprehensive YAML language support for Visual Studio Code.

Install the Kubernetes Templates plug-in, which can help us generate K8S resource YAML template files in one click.

After the above two plug-ins are installed, restart vscode.

Basic Use

The usage is also very simple. Open vscode, create a new file, and then select YAML as the file format, as shown below:

For example, if we want to create a deploy template file, we only need to enter k in the file, and then vscode will intelligently prompt all templates starting with k, as shown in the following figure:

When we select k8sDeployment and press Enter, a very detailed template will be generated. As shown in the following figure:

This tool is really great. It allows us to no longer worry about finding K8S resource templates. It covers almost all K8S resource files. After using it, our work efficiency has been significantly improved.

<<: 

>>: 

Recommend

How Apple's iCloud Private Relay powers enterprise VPNs

Apple's iCloud Private Relay service offers p...

Intranet master-slave smart DNS, no more worries

[[432985]] This article is reprinted from the WeC...

A brief history of Wi-Fi security protocols, from zero to WPA3

With the continuous development of WI-FI, we will...

The high-quality development of 5G still requires more active policy support

Recently, the three major telecom operators have ...

What exactly is a socket? Do you want to know?

I believe that everyone was like me when they fir...

SASE vs. SD-WAN: Which one do you pick?

SASE (Secure Access Service Edge) and SD-WAN are ...

IPv4 and IPv6: Is the Internet Facing a Split?

The Internet is facing a technological split, and...

Quantum computing will impact businesses despite misunderstandings, study shows

Nanotechnology, transportation, cybersecurity and...