apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nexus-ingress
namespace: devops
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: nexus.zm.com
http:
paths:
- path: /
backend:
serviceName: nexus
servicePort: 8081
---
apiVersion: v1
kind: Service
metadata:
name: nexus
namespace: devops
labels:
app: nexus
spec:
ports:
- name: nexus
port: 8081
targetPort: 8081
protocol: TCP
selector:
app: nexus
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nexus
namespace: devops
labels:
app: nexus
spec:
replicas: 1
selector:
matchLabels:
app: nexus
template:
metadata:
labels:
app: nexus
spec:
securityContext:
runAsUser: 0
nodeSelector:
kubernetes.io/hostname: k12-k8s-node-03
containers:
- name: nexus
image: sonatype/nexus3
imagePullPolicy: IfNotPresent
ports:
- name: server
containerPort: 8081
livenessProbe: #存活探针
httpGet:
path: /
port: 8081
initialDelaySeconds: 30
periodSeconds: 30
failureThreshold: 6
readinessProbe: #就绪探针
httpGet:
path: /
port: 8081
initialDelaySeconds: 30
periodSeconds: 30
failureThreshold: 6
env:
- name: INSTALL4J_ADD_VM_PARAMS #设置分配资源大小,一定要等于或小于resources设置的值
value: "
-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockExperimentalVMOptions
-XX:+UseCGroupMemoryLimitForHeap
"
resources:
limits:
cpu: 1000m #推荐设置为4000m以上cpu,由于资源有限,所以都是设置的最小值
memory: 2048Mi
requests:
cpu: 500m
memory: 1024Mi
volumeMounts:
- name: nexus-data
mountPath: /nexus-data
volumes:
- name: nexus-data
hostPath:
path: /data/nexus
数据存储直接使用的 hostPath,并通过 nodeSelector固定节点,实际使用时修改