Kubernetes Cloud Native 实践 ( 五 ) 应用上云
2023-06-13 20:53:40 459
全文目录
Kubernetes Cloud Native 实践 ( 一 ) 安装
Kubernetes Cloud Native 实践 ( 二 ) 简单使用
Kubernetes Cloud Native 实践 ( 三 ) NFS/PV/PVC
Kubernetes Cloud Native 实践 ( 四 ) 中间件上云
Kubernetes Cloud Native 实践 ( 五 ) 应用上云
Kubernetes Cloud Native 实践 ( 六 ) 集成ELK日志平台
Kubernetes Cloud Native 实践 ( 七 ) 应用监控
Kubernetes Cloud Native 实践 ( 八 ) CICD集成
Kubernetes Cloud Native 实践 ( 九 ) 运维管理
Kubernetes Cloud Native 实践 ( 十 ) 相关问题
Kubernetes Cloud Native 实践 ( 十一 ) 运行截图
- 应用上云
apiVersion: v1
kind: Namespace
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Namespace","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"app","app.kubernetes.io/name":"app"},"name":"app"}}
labels:
app.kubernetes.io/instance: app
app.kubernetes.io/name: app
name: app
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"StatefulSet","metadata":{"annotations":{},"name":"user-api","namespace":"app"}}
name: user-api
namespace: app
spec:
replicas: 1
serviceName: user-api
selector:
matchLabels:
app: user-api
template:
metadata:
name: user-api-pod
labels:
app: user-api
spec:
imagePullSecrets:
- name: aliyun-docker
containers:
- name: user-api-container
image: registry.cn-hangzhou.aliyuncs.com/thy-k8s/user-api:latest
resources:
limits:
memory: "520Mi"
cpu: "200m"
ports:
- containerPort: 8001
env:
- name: JAVA_OPTS
value: "-javaagent:/home/java/skywalking-agent/skywalking-agent.jar -Xms256m -Xmx512m"
- name: APP_OPTS
value: >
-Dspring.profiles.active=prod
-Dspring.cloud.nacos.discovery.server-addr=nacos-headless.nacos
-Dspring.cloud.nacos.discovery.namespace=19a0fa32-ed2e-40f1-a1e1-aae8c81d8cf8
-Dskywalking.agent.service_name=user-api
-Dskywalking.collector.backend_service=skywalking-oap.skywalking-oap:11800
volumeMounts:
- name: log
mountPath: "/data/logs/user-api/"
volumeClaimTemplates:
- metadata:
name: log
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: user-api
namespace: app
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"name":"user-api","namespace":"app"}}
spec:
type: NodePort
selector:
app: user-api
ports:
- name: http
protocol: TCP
nodePort: 30088
port: 80
targetPort: 8001
- user-web
apiVersion: v1
kind: Namespace
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Namespace","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"app","app.kubernetes.io/name":"app"},"name":"app"}}
labels:
app.kubernetes.io/instance: app
app.kubernetes.io/name: app
name: app
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"StatefulSet","metadata":{"annotations":{},"name":"user-web","namespace":"app"}}
name: user-web
namespace: app
spec:
replicas: 1
serviceName: user-web
selector:
matchLabels:
app: user-web
template:
metadata:
name: user-web-pod
labels:
app: user-web
spec:
imagePullSecrets:
- name: aliyun-docker
containers:
- name: user-web-container
image: registry.cn-hangzhou.aliyuncs.com/thy-k8s/user-web:latest
resources:
limits:
memory: "520Mi"
cpu: "200m"
ports:
- containerPort: 9001
env:
- name: JAVA_OPTS
value: "-javaagent:/home/java/skywalking-agent/skywalking-agent.jar -Xms256m -Xmx512m"
- name: APP_OPTS
value: >
-Dspring.profiles.active=prod
-Dspring.cloud.nacos.discovery.server-addr=nacos-headless.nacos
-Dspring.cloud.nacos.discovery.namespace=19a0fa32-ed2e-40f1-a1e1-aae8c81d8cf8
-Dskywalking.agent.service_name=user-web
-Dskywalking.collector.backend_service=skywalking-oap.skywalking-oap:11800
volumeMounts:
- name: log
mountPath: "/data/logs/user-web/"
volumeClaimTemplates:
- metadata:
name: log
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: user-web
namespace: app
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"name":"user-web","namespace":"app"}}
spec:
type: NodePort
selector:
app: user-web
ports:
- name: http
protocol: TCP
nodePort: 30188
port: 80
targetPort: 9001
- record-web
apiVersion: v1
kind: Namespace
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Namespace","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"app","app.kubernetes.io/name":"app"},"name":"app"}}
labels:
app.kubernetes.io/instance: app
app.kubernetes.io/name: app
name: app
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"StatefulSet","metadata":{"annotations":{},"name":"record-web","namespace":"app"}}
name: record-web
namespace: app
spec:
replicas: 1
serviceName: record-web
selector:
matchLabels:
app: record-web
template:
metadata:
name: record-web-pod
labels:
app: record-web
spec:
imagePullSecrets:
- name: aliyun-docker
containers:
- name: record-web-container
image: registry.cn-hangzhou.aliyuncs.com/thy-k8s/record-web:latest
resources:
limits:
memory: "520Mi"
cpu: "200m"
ports:
- containerPort: 9002
env:
- name: JAVA_OPTS
value: "-javaagent:/home/java/skywalking-agent/skywalking-agent.jar -Xms256m -Xmx512m"
- name: APP_OPTS
value: >
-Dspring.profiles.active=prod
-Dspring.cloud.nacos.discovery.server-addr=nacos-headless.nacos
-Dspring.cloud.nacos.discovery.namespace=19a0fa32-ed2e-40f1-a1e1-aae8c81d8cf8
-Dskywalking.agent.service_name=record-web
-Dskywalking.collector.backend_service=skywalking-oap.skywalking-oap:11800
volumeMounts:
- name: log
mountPath: "/data/logs/record-web/"
volumeClaimTemplates:
- metadata:
name: log
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: record-web
namespace: app
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"name":"record-web","namespace":"app"}}
spec:
type: NodePort
selector:
app: record-web
ports:
- name: http
protocol: TCP
nodePort: 30288
port: 80
targetPort: 9002