FROM golang:1.12 as build
ENV GIN_MODE release
ENV GOPROXY https://goproxy.io
ENV GO111MODULE on
WORKDIR /go/cache
ADD go.mod .
RUN go mod tidy
RUN go mod download
WORKDIR /go/release
ADD . .
RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix cgo -o echowebvue main.go
FROM nginx as production-stage
COPY --from=build /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY --from=build /go/release/. /
CMD ["/echowebvue"]
[root@k8s-master xiangmu]# cat echowebvue.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: echowebvue
  name: echowebvue
spec:
  replicas: 1
  selector:
    matchLabels:
      app: echowebvue
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: echowebvue

  
    spec:
      containers:
        - name: echowebvue
          image: 10.1.1.11/library/echowebvue:6 
          ports:
          - containerPort: 55555
          resources:
            limits:
              cpu: 1
              memory: 2Gi
            requests:
              cpu: 0.5
              memory: 1Gi


---
apiVersion: v1
kind: Service
metadata:
  name: echowebvue
spec:
  type: NodePort
  selector:
    app: echowebvue 
  ports:
    - protocol: TCP
      port: 55555
      targetPort: 55555

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: echowebvue 
  namespace: default
spec:
  rules:
  - host: echowebvue.rpdns.com
    http:
      paths:
      - path: /
        backend:
          serviceName: echowebvue 
          servicePort: 55555

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐