How to create a YAML file?
It is very easy and simple to create a YAML file, there are mainly three ways to create a YAML file if you want, let’s see what those ways are and also understand each method one by one.
Method 1: Use Any Online Tool for YAML or Text Editor:
Step 1: Use any online tool that helps you to convert the code into indented YAML data,
Step 2: for example we have the following data that we will use for conversion:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Step 3: Then simply go to any online converter website for YAML, for example I have this website that can do so:
https://jsonformatter.org/yaml-parser
Step 4: This will give you the YAML code and then you can download the YAML file as well by using the download button.
Method 2: Create a file using the YAML URL:
As you know that some developers also work with data and file that are stored on the cloud servers and almost 90% of the data is hosted mostly on the Azure, Google Cloud, DigitalOcean etc. so developers can simply use the remote URL to save and edit the YAML files that are stored in the servers.
Here is a sample of the YAML URL. Now you can simply click on these YAML sample to view it.
https://github.com/kishan-kaushik/git-project/blob/master/file.yaml
Method 3. Create the YAML file using YAML Template:
YAML is used for configuration files which means that we need to avoid most of the mistakes for this you always need to take precaution and use the right template, for example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
What Type of Language is YAML?
As we know the world of technology is filled with various modern and old languages which keep changing from time to time, each one of these languages serves a specific purpose and thus each language is used for performing certain tasks only. But when it comes to the programming language called YAML people sometimes get confused because they have trouble understanding what type of programming language YAML is, so in this article, we will understand what type of language the YAML programming language is.
Contact Us