Skip to content

Commit a6801af

Browse files
committed
Added VSCode snippets for easier MCS-related manifest scripting
1 parent 12338df commit a6801af

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed
63.1 KB
Loading
86.9 KB
Loading

site-src/references/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Snippets for Visual Studio Code
2+
The file [yaml.json](./yaml.json) in this folder can be appended to your Visual Studio Code user configuration YAML edition preferences `(\${HOME}/.config/Code/\${USER}/yaml.json)` to enable a simplified experience when writing MCS-related manifests.
3+
> As the yaml.json contains all personalized snippets, it is recommended to append the contents and not copy over the file.
4+
5+
Once the snippets are copied over, create a new YAML file, and press `CTRL + Space`, and you should see a list of snippets available.
6+
7+
![Snippets drop-down selection in VSCode](../images/snippet-selection.png)
8+
9+
10+
If you select, say for example, the ServiceImport snippet, your file will be pre-filled with the corresponding snippet. Using the tab key, you can navigate easily between the different values that you may want to change.
11+
12+
![Pre-populated snippet in VSCode](../images/prepopulated-snippet.png)

site-src/references/yaml.json

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"Work": {
3+
"prefix": ["Work"],
4+
"body": [
5+
"apiVersion: multicluster.x-k8s.io/v1alpha1",
6+
"kind: Work",
7+
"metadata:",
8+
"\tname: ${1:work-name}",
9+
"\tnamespace: ${2:cluster-name}",
10+
"spec:",
11+
"\tworkload:",
12+
"\t\tmanifests:",
13+
"\t\t- apiVersion: v1",
14+
"\t\t kind: $3",
15+
"\t\t metadata: $4",
16+
"\t\t namespace: $5"
17+
],
18+
"description": "Work object as described in the Work API (https://github.com/kubernetes-sigs/work-api)"
19+
},
20+
"ServiceImport": {
21+
"prefix": ["ServiceImport"],
22+
"body": [
23+
"apiVersion: multicluster.x-k8s.io/v1alpha1",
24+
"kind: ServiceImport",
25+
"metadata:",
26+
"\tname: ${1:service-name}",
27+
"\tnamespace: ${2:demo}",
28+
"spec:",
29+
"\ttype: ${3:ClusterSetIP}",
30+
"\tips:",
31+
"\t- ${4:1.2.3.4}",
32+
"\tports:",
33+
"\t- name: ${5:http}",
34+
"\t protocol: TCP",
35+
"\t port: ${6:80}"
36+
],
37+
"description": "ServiceImport object as described in the Multicluster API (https://github.com/kubernetes-sigs/mcs-api/)"
38+
},
39+
"ServiceExport": {
40+
"prefix": ["ServiceExport"],
41+
"body": [
42+
"apiVersion: multicluster.x-k8s.io/v1alpha1",
43+
"kind: ServiceExport",
44+
"metadata:",
45+
"\tname: ${1:service-name}",
46+
"\tnamespace: ${2:demo}"
47+
],
48+
"description": "ServiceImport object as described in the Multicluster API (https://github.com/kubernetes-sigs/mcs-api/)"
49+
},
50+
"EndPointSlice": {
51+
"prefix": ["EndPointSlice"],
52+
"body": [
53+
"apiVersion: discovery.k8s.io/v1beta1",
54+
"kind: EndPointSlice",
55+
"metadata:",
56+
"\tname: ${1:imported-service-cluster-name}",
57+
"\tnamespace: ${2:demo}",
58+
"\tlabels:",
59+
"\t\tmulticluster.kubernetes.io/source-cluster: us-west2-a-my-cluster",
60+
"\t\tmulticluster.kubernetes.io/service-name: my-svc",
61+
"\townerReferences:",
62+
"\t- apiVersion: multicluster.k8s.io/v1alpha1",
63+
"\t controller: false",
64+
"\t kind: ServiceImport",
65+
"\t name: my-svc",
66+
"addressType: ${3:IPv4}",
67+
"ports:",
68+
"\t- name: http",
69+
"\t protocol: TCP",
70+
"\t port: ${4:80}",
71+
"endpoints:",
72+
"\t- addresses:",
73+
"\t\t- ${5:10.1.2.3}",
74+
"\t conditions:",
75+
"\t\t ready: true",
76+
"\t hostname: ${6:pod-1}",
77+
"\t nodeName: ${7:node-1}",
78+
"\t zone: ${8:us-west2-a}"
79+
],
80+
"description": "EndPointSlice object as described in https://kubernetes.io/docs/concepts/services-networking/endpoint-slices/"
81+
},
82+
"ClusterSet (About API)": {
83+
"prefix": ["ClusterSet"],
84+
"body": [
85+
"apiVersion: about.k8s.io/v1",
86+
"kind: ClusterProperty",
87+
"metadata:",
88+
"\tname: clusterset.k8s.io",
89+
"spec:",
90+
"\tvalue: ${1:clusterset-1}"
91+
],
92+
"description": "ClusterSet object as described in the About API (https://github.com/kubernetes/enhancements/tree/master/keps/sig-multicluster/2149-clusterid)"
93+
},
94+
"Cluster (About API)": {
95+
"prefix": ["Cluster"],
96+
"body": [
97+
"apiVersion: about.k8s.io/v1",
98+
"kind: ClusterProperty",
99+
"metadata:",
100+
"\tname: cluster.clusterset.k8s.io",
101+
"spec:",
102+
"\tvalue: ${1:cluster-1}"
103+
],
104+
"description": "Cluster object as described in the About API (https://github.com/kubernetes/enhancements/tree/master/keps/sig-multicluster/2149-clusterid)"
105+
}
106+
107+
}

0 commit comments

Comments
 (0)