deployment.yaml
使用hostAliases将hosts解析写入pod中的/etc/hosts
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: tomcat8
name: tomcat8
namespace: default
spec:
replicas: 1
selector:
matchLabels:
k8s-app: tomcat8
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
k8s-app: tomcat8
spec:
containers:
- image: ccr.ccs.tencentyun.com/ecool_tomcat8/centos7-jdk1.8-tomcat8:v3
imagePullPolicy: IfNotPresent
name: tomcat8
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 250m
memory: 256Mi
dnsPolicy: ClusterFirst
restartPolicy: Always
hostAliases:
- hostnames:
- logdb1
ip: 172.17.0.
- hostnames:
- confcdb1
ip: 172.17.0.
service.yaml
service通过NodePort方式访问endpoints
apiVersion: v1
kind: Service
metadata:
name: tomcat8
namespace: default
spec:
ports:
- name: 8080-8080-tcp
nodePort: 30000
port: 8080
protocol: TCP
targetPort: 8080
selector:
k8s-app: tomcat8
sessionAffinity: None
type: NodePort
网友评论