Skip to content

Instantly share code, notes, and snippets.

@uurtech
Created May 13, 2020 21:15
Show Gist options
  • Save uurtech/00fb650a07a97b93bad1714a0664fe79 to your computer and use it in GitHub Desktop.
Save uurtech/00fb650a07a97b93bad1714a0664fe79 to your computer and use it in GitHub Desktop.
Kubernetes app that can access to gcloud vms
FROM golang:latest
COPY main.go main.go
RUN go get github.com/joho/godotenv
RUN go get github.com/lib/pq
RUN go get golang.org/x/oauth2/google
RUN go get google.golang.org/api/compute/v1
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
FROM alpine:latest as certs
RUN apk --update add ca-certificates
FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=0 /go/main .
COPY ./.env .
COPY ./credentials.json .
CMD ["./main"]
#we need to use service account because k8s container wants to use that to access to vms, and it needs certs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment