安装goctl
GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
goctl kube deploy -name nginx -namespace test -image nginx:alpine -replicas 1 -minReplicas 1 -maxReplicas 3 -o nginx-j.yaml -port 80 -nodePort 31330
结果如下
apiVersion: apps/v1
kind: Deployment
metadata:name: nginxnamespace: testlabels:app: nginx
spec:replicas: 1revisionHistoryLimit: 5selector:matchLabels:app: nginxtemplate:metadata:labels:app: nginxspec:containers:- name: nginximage: nginx:alpinelifecycle:preStop:exec:command: ["sh","-c","sleep 5"]ports:- containerPort: 80readinessProbe:tcpSocket:port: 80initialDelaySeconds: 5periodSeconds: 10livenessProbe:tcpSocket:port: 80initialDelaySeconds: 15periodSeconds: 20resources:requests:cpu: 500mmemory: 512Milimits:cpu: 1000mmemory: 1024MivolumeMounts:- name: timezonemountPath: /etc/localtimevolumes:- name: timezonehostPath:path: /usr/share/zoneinfo/Asia/Shanghai---apiVersion: v1
kind: Service
metadata:name: nginx-svcnamespace: test
spec:ports:- nodePort: 31330port: 80protocol: TCPtargetPort: 80type: NodePortselector:app: nginx---apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:name: nginx-hpa-cnamespace: testlabels:app: nginx-hpa-c
spec:scaleTargetRef:apiVersion: apps/v1kind: Deploymentname: nginxminReplicas: 1maxReplicas: 3metrics:- type: Resourceresource:name: cputargetAverageUtilization: 80---apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:name: nginx-hpa-mnamespace: testlabels:app: nginx-hpa-m
spec:scaleTargetRef:apiVersion: apps/v1kind: Deploymentname: nginxminReplicas: 1maxReplicas: 3metrics:- type: Resourceresource:name: memorytargetAverageUtilization: 80