k8s-gateway
约 234 字小于 1 分钟
# 网关
---
apiVersion: v1
kind: Service
metadata:
name: gateway
namespace: demo
spec:
type: NodePort
selector:
app: gateway
environment: dev
ports:
- name: http
protocol: TCP
port: 8201
targetPort: 8201
nodePort: 31201
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gateway
namespace: demo
labels:
app: gateway
environment: dev
spec:
replicas: 2
selector:
matchLabels:
app: gateway
environment: dev
template:
metadata:
labels:
app: gateway
environment: dev
spec:
imagePullSecrets:
- name: registrysecret
initContainers:
- name: init-mysql
image: yauritux/busybox-curl
command: [ 'sh', '-c', "until curl --http0.9 mysql.demo.svc.cluster.local:3306; do echo waiting for mysql; sleep 2; done" ]
- name: init-nacos
image: yauritux/busybox-curl
command: [ 'sh', '-c', "until curl nacos-hs.demo.svc.cluster.local:8848; do echo waiting for nacos; sleep 2; done" ]
- name: init-kafka
image: busybox:1.28
command: [ 'sh', '-c', "until nslookup kafka.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for kafka; sleep 1; done" ]
containers:
- name: gateway
image: gateway:1.3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8201
protocol: TCP
resources:
requests:
cpu: 250m
memory: 500Mi
limits:
cpu: 1000m
memory: 2Gi
env:
- name: spring.profiles.active
value: dev
- name: JAVA_TOOL_OPTIONS
value: -Xmx512m -Xms512m -XX:MaxMetaspaceSize=256m
- name: SW_AGENT_NAME
value: gateway
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: skywalking-oap.monitor:11800
volumeMounts:
- mountPath: /etc/localtime
name: time-localtime
readOnly: true
- mountPath: /opt/gateway/logs
name: log-volume
volumes:
- name: time-localtime
hostPath:
path: /etc/localtime
- name: log-volume
hostPath:
path: /opt/software/data/gateway/logs
type: DirectoryOrCreate