YAML ↔ JSON
把 YAML 配置转换成 JSON,也能反向转换,支持缩进控制和 Kubernetes、GitHub Actions 预设。
完全在浏览器中运行 — 粘贴的内容不会被上传。
支持映射、序列、流式写法、带引号字符串、块标量和注释。不展开锚点、别名和标签。
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "ryuslog-web",
"labels": {
"app": "ryuslog",
"tier": "frontend"
}
},
"spec": {
"replicas": 3,
"selector": {
"matchLabels": {
"app": "ryuslog"
}
},
"template": {
"metadata": {
"labels": {
"app": "ryuslog"
}
},
"spec": {
"containers": [
{
"name": "web",
"image": "ghcr.io/ryuslog/web:1.4.0",
"ports": [
{
"containerPort": 3000
}
],
"env": [
{
"name": "NODE_ENV",
"value": "production"
}
],
"resources": {
"limits": {
"cpu": "500m",
"memory": "512Mi"
}
},
"readinessProbe": {
"httpGet": {
"path": "/api/health",
"port": 3000
},
"initialDelaySeconds": 5,
"periodSeconds": 10
}
}
]
}
}
}
}YAML 语法参考
快速参考- key: value
- 映射条目。冒号后必须有空格,缩进必须使用空格而不是制表符。
- - item
- 该缩进层级上的序列条目;条目的子键与条目文字对齐。
- |
- 保留换行的字面块标量,多行 shell 脚本和配置文件常用。
- >
- 把换行合并为空格的折叠块标量,适合一段很长的文字。
- [a, b] / {k: v}
- 在一行内书写简短序列或映射的流式简写。
- # comment
- 注释延续到行尾,转换为 JSON 时会丢失。
Kubernetes 相关语法指南
全部 Kubernetes 指南Kubernetes Pending Pod: CPU Requests, Unbound PVC, Taints
The scheduler event names every node and its reason. Requests versus allocatable, untolerated taints, zonal volume binding, and impossible anti-affinity.
KubernetesKubernetes Exit Code 137 OOMKilled vs Exit Code 134 Heap Limits
137 is SIGKILL from the cgroup or a liveness probe; 134 is an abort, usually V8's own heap ceiling. Telling them apart and sizing the two limits together.
KubernetesCrashLoopBackOff: Reading Exit Codes and Debugging Restart Loops
The backoff is only the waiting state. The evidence is in Last State, the exit code, and the previous container's last log line, and each points to a different fix.
KubernetesImagePullBackOff and ErrImagePull: Reading the Real Pull Error
ImagePullBackOff hides five different failures. The event text names which one: wrong reference, missing credentials, wrong architecture, unreachable registry, or a rate limit.