Kubernetes 服务 Yaml 样例

Kubernetes 服务 Yaml 样例

简介

本文是在 Kubernetes 中部署一个简单服务的 Yaml 记录。

样例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
apiVersion: v1
kind: Namespace
metadata:
name: demo
---

apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-deployment
labels:
app: tomcat
namespace: demo
spec:
replicas: 1
selector:
matchLabels:
app: tomcat
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat
image: tomcat:9.0
ports:
- containerPort: 8080
---

kind: Service
apiVersion: v1
metadata:
labels:
app: tomcat
name: tomcat-svc
namespace: demo
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: tomcat
---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tomcat-ingress
namespace: demo
spec:
ingressClassName: nginx
rules:
- host: <host>
http:
paths:
- backend:
service:
name: tomcat-svc
port:
number: 8080
path: /
pathType: Prefix
status:
loadBalancer: {}

参考资料

官方文档


Kubernetes 服务 Yaml 样例
https://wangqian0306.github.io/2022/kubernetes-yaml/
作者
WangQian
发布于
2022年12月20日
许可协议