Skip to content

Commit 1a8161b

Browse files
authored
Merge pull request #500 from legal90/fix-konfig-guide
Fix typos and outdated info in Konfig guide
2 parents 719b308 + 419433e commit 1a8161b

File tree

3 files changed

+94
-87
lines changed

3 files changed

+94
-87
lines changed

docs/user_docs/guides/working-with-konfig/2-structure.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,31 @@ The core model library is generally named `models`, mainly including front-end m
1414
```bash
1515
models
1616
├── commons # Common models
17-
├── kube # Cloud-native resource core models
18-
│ ├── backend # Back-end models
19-
│ ├── frontend # Front-end models
20-
│ │ ├── common # Common front-end models
21-
│ │ ├── configmap # ConfigMap
22-
│ │ ├── container # Container
23-
│ │ ├── ingress # Ingress
24-
│ │ ├── resource # Resource
25-
│ │ ├── secret # Secret
26-
│ │ ├── service # Service
27-
│ │ ├── sidecar # Sidecar
28-
│ │ ├── strategy # strategy
29-
│ │ ├── volume # Volume
30-
│ │ └── server.k # The `Server` model
31-
│ ├── metadata # Kubernetes metadata
32-
│ ├── mixins # Mixin
33-
│ ├── render # Front-to-back-end renderers.
34-
│ ├── templates # Data template
35-
│ └── utils
36-
└── metadata # Common metadata
17+
└── kube # Cloud-native resource core models
18+
├── backend # Back-end models
19+
├── frontend # Front-end models
20+
│   ├── affinity # Affinity
21+
│   ├── deployment # Deplyment
22+
│ ├── common # Common front-end models
23+
│ ├── configmap # ConfigMap
24+
│ ├── container # Container
25+
│ ├── ingress # Ingress
26+
│   ├── rbac # Role, RoleBinding, ClusterRole, ClusterRoleBinding
27+
│ ├── resource # Resource
28+
│ ├── secret # Secret
29+
│ ├── service # Service
30+
│   ├── serviceaccount # ServiceAccount
31+
│ ├── sidecar # Sidecar
32+
│   ├── storage # DataBase, ObjectStorage
33+
│ ├── strategy # SchedulingStrategy
34+
│ ├── volume # Volume
35+
│   ├── job.k # The `Job` model
36+
│ └── server.k # The `Server` model
37+
├── metadata # Kubernetes metadata
38+
├── mixins # Mixin
39+
├── protocol # ServerProtocol
40+
├── render # Front-to-back-end renderers.
41+
├── resource # ResourceMapping
42+
├── templates # Data template
43+
└── utils # Helper utils
3744
```

docs/user_docs/guides/working-with-konfig/3-quick-start.md

Lines changed: 61 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The programming language of the project is KCL, not JSON/YAML which Kubernetes r
4141
Enter stack dir `examples/appops/nginx-example/dev` and compile:
4242

4343
```bash
44-
cd examples/appops/nginx-example/dev && kcl run -D env=dev
44+
cd examples/appops/nginx-example/dev && kcl run -D appenv=dev
4545
```
4646

4747
The output YAML is:
@@ -50,71 +50,71 @@ The output YAML is:
5050
apiVersion: apps/v1
5151
kind: Deployment
5252
metadata:
53-
name: sampleappdev
54-
namespace: sampleapp
53+
name: sampleapp-dev
54+
namespace: sampleappns-dev
5555
spec:
5656
replicas: 1
5757
selector:
5858
matchLabels:
5959
app.kubernetes.io/name: sampleapp
6060
app.kubernetes.io/env: dev
6161
app.kubernetes.io/instance: sampleapp-dev
62-
app.k8s.io/component: sampleappdev
62+
app.k8s.io/component: sampleapp-dev
6363
template:
6464
metadata:
6565
labels:
6666
app.kubernetes.io/name: sampleapp
6767
app.kubernetes.io/env: dev
6868
app.kubernetes.io/instance: sampleapp-dev
69-
app.k8s.io/component: sampleappdev
69+
app.k8s.io/component: sampleapp-dev
7070
spec:
7171
containers:
72-
- env:
73-
- name: MY_ENV
74-
value: MY_VALUE
75-
image: nginx:1.7.8
76-
name: main
77-
ports:
78-
- containerPort: 80
79-
protocol: TCP
80-
resources:
81-
limits:
82-
cpu: "100m"
83-
memory: "100Mi"
84-
ephemeral-storage: "1Gi"
85-
requests:
86-
cpu: "100m"
87-
memory: "100Mi"
88-
ephemeral-storage: "1Gi"
89-
volumeMounts: []
72+
- env:
73+
- name: MY_ENV
74+
value: MY_VALUE
75+
image: nginx:1.7.8
76+
name: main
77+
ports:
78+
- containerPort: 80
79+
protocol: TCP
80+
resources:
81+
limits:
82+
cpu: '100m'
83+
memory: '100Mi'
84+
ephemeral-storage: '1Gi'
85+
requests:
86+
cpu: '100m'
87+
memory: '100Mi'
88+
ephemeral-storage: '1Gi'
89+
volumeMounts: []
9090
---
9191
apiVersion: v1
9292
kind: Namespace
9393
metadata:
94-
name: sampleapp
94+
name: sampleappns-dev
9595
---
9696
apiVersion: v1
9797
kind: Service
9898
metadata:
9999
name: nginx
100-
namespace: sampleapp
100+
namespace: sampleappns-dev
101101
spec:
102102
ports:
103-
- nodePort: 30201
104-
port: 80
105-
targetPort: 80
103+
- nodePort: 30201
104+
port: 80
105+
targetPort: 80
106106
selector:
107107
app.kubernetes.io/name: sampleapp
108108
app.kubernetes.io/env: dev
109109
app.kubernetes.io/instance: sampleapp-dev
110-
app.k8s.io/component: sampleappdev
110+
app.k8s.io/component: sampleapp-dev
111111
type: NodePort
112112
```
113113
114114
After compiling, we can see three resources:
115115
116-
- A `Deployment` with the name `sampleappprod`
117-
- A `Namespace` with the name `sampleapp`
116+
- A `Deployment` with the name `sampleapp-dev`
117+
- A `Namespace` with the name `sampleappns-dev`
118118
- A `Service` with the name `nginx`
119119

120120
### 2. Modification
@@ -131,71 +131,72 @@ The `image` attribute in the `Server` model is used to declare the application's
131131
Recompile the configuration code to obtain the modified YAML output:
132132

133133
```shell
134-
kcl run
134+
kcl run -D appenv=dev
135135
```
136136

137137
```yaml
138138
apiVersion: apps/v1
139139
kind: Deployment
140140
metadata:
141-
name: sampleappdev
142-
namespace: sampleapp
141+
name: sampleapp-dev
142+
namespace: sampleappns-dev
143143
spec:
144144
replicas: 1
145145
selector:
146146
matchLabels:
147147
app.kubernetes.io/name: sampleapp
148148
app.kubernetes.io/env: dev
149149
app.kubernetes.io/instance: sampleapp-dev
150-
app.k8s.io/component: sampleappdev
150+
app.k8s.io/component: sampleapp-dev
151151
template:
152152
metadata:
153153
labels:
154154
app.kubernetes.io/name: sampleapp
155155
app.kubernetes.io/env: dev
156156
app.kubernetes.io/instance: sampleapp-dev
157-
app.k8s.io/component: sampleappdev
157+
app.k8s.io/component: sampleapp-dev
158158
spec:
159159
containers:
160-
- env:
161-
- name: MY_ENV
162-
value: MY_VALUE
163-
image: nginx:latest
164-
name: main
165-
ports:
166-
- containerPort: 80
167-
protocol: TCP
168-
resources:
169-
limits:
170-
cpu: "100m"
171-
memory: "100Mi"
172-
ephemeral-storage: "1Gi"
173-
requests:
174-
cpu: "100m"
175-
memory: "100Mi"
176-
ephemeral-storage: "1Gi"
177-
volumeMounts: []
160+
- env:
161+
- name: MY_ENV
162+
value: MY_VALUE
163+
image: nginx:1.7.8
164+
name: main
165+
ports:
166+
- containerPort: 80
167+
protocol: TCP
168+
resources:
169+
limits:
170+
cpu: '100m'
171+
memory: '100Mi'
172+
ephemeral-storage: '1Gi'
173+
requests:
174+
cpu: '100m'
175+
memory: '100Mi'
176+
ephemeral-storage: '1Gi'
177+
volumeMounts: []
178178
---
179179
apiVersion: v1
180180
kind: Namespace
181181
metadata:
182-
name: sampleapp
182+
name: sampleappns-dev
183183
---
184184
apiVersion: v1
185185
kind: Service
186186
metadata:
187187
name: nginx
188-
namespace: sampleapp
188+
namespace: sampleappns-dev
189189
spec:
190190
ports:
191-
- nodePort: 30201
192-
port: 80
193-
targetPort: 80
191+
- nodePort: 30201
192+
port: 80
193+
targetPort: 80
194194
selector:
195195
app.kubernetes.io/name: sampleapp
196196
app.kubernetes.io/env: dev
197197
app.kubernetes.io/instance: sampleapp-dev
198-
app.k8s.io/component: sampleappdev
198+
app.k8s.io/component: sampleapp-dev
199+
type: NodePort
199200
```
200201

201202
## Resources

docs/user_docs/guides/working-with-konfig/4-best-practice.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ schema SLI:
8787
8888
The type of template is a combination of two string types, indicating that the template can only be `"success_ratio"` or `"service_cost"`. When the user fills in the values of other strings, the KCL compiler will report an error.
8989
90-
In addition to using union types for literal types, KCL also supports union for complex types such as schema types. For the support of this backend **oneof** configuration, KCL has built-in composite structure union types for support. For example, we can define our own SLI front-end types for various scenarios: `CustomSliDataSource`, `PQLSLIDataSource`, and `StackSLIDataSource`.
90+
In addition to using union types for literal types, KCL also supports union for complex types such as schema types. For the support of this backend **oneof** configuration, KCL has built-in composite structure union types for support. For example, we can define our own SLI front-end types for various scenarios: `CustomSLIDataSource`, `PQLSLIDataSource`, and `StackSLIDataSource`.
9191

9292
```python
9393
schema CustomSLIDataSource:
@@ -175,7 +175,7 @@ house = House {
175175
}
176176
```
177177

178-
For example, in the above example, if you want to query the age of the person named `"Alice"` from the list of persons in the house, you need to loop through the list to find Alice's age. However, if you define persons as a dictionary like the following code, it not only looks more concise in code, but you can also directly retrieve Alice's age by using house.persons.Alice.age. In addition, the information of the entire configuration is complete and has no redundant information.
178+
For example, in the above example, if you want to query the age of the person named `"Alice"` from the list of persons in the house, you need to loop through the list to find Alice's age. However, if you define persons as a dictionary like the following code, it not only looks more concise in code, but you can also directly retrieve Alice's age by using `house.persons.Alice.age`. In addition, the information of the entire configuration is complete and has no redundant information.
179179

180180
```python
181181
schema Person:
@@ -346,11 +346,10 @@ The output is
346346

347347
```yaml
348348
cpuMap:
349-
"1": 256
350-
"2": 512
351-
"3": 1024
352-
cpu256: 256
353-
cpu2048: 2048
349+
'1': 256
350+
'2': 512
351+
'3': 1024
352+
cpu: 256
354353
```
355354
356355
### Separate Logic and Data

0 commit comments

Comments
 (0)