Skip to content
This repository was archived by the owner on Jan 11, 2021. It is now read-only.

Adding of a k8s manifest #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ credentials/*
.DS_Store
vendor
.env
used-manifest.k8s.yml

# Binaries for programs and plugins
*.exe
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM golang:1.9 AS build
WORKDIR /go/src/ecr_reverse_proxy/
FROM golang:1.11 AS build
RUN apt-get update && apt-get install unzip
RUN cd /tmp && wget -L https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 && mv dep-linux-amd64 dep && chmod +x dep
COPY Gopkg.* /go/src/ecr_reverse_proxy/
WORKDIR /go/src/github.com/marjamis/ecr_reverse_proxy/
COPY Gopkg.* ./
RUN /tmp/dep ensure --vendor-only
COPY *.go /go/src/ecr_reverse_proxy/
COPY *.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ecr_reverse_proxy .

FROM alpine:latest
FROM alpine:3.8
LABEL maintainer=marjamis
RUN apk --no-cache add ca-certificates && mkdir /.ecr/ && chown nobody:nobody /.ecr/
USER nobody
WORKDIR /app/
COPY --from=build /go/src/ecr_reverse_proxy/ecr_reverse_proxy .
COPY --from=build /go/src/github.com/marjamis/ecr_reverse_proxy .
ENTRYPOINT ["./ecr_reverse_proxy"]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ build:

run: checks
TLS_CERTIFICATE=$(TLS_CERTIFICATE) TLS_PRIVATE_KEY=$(TLS_PRIVATE_KEY) REGION=$(REGION) REGISTRY=$(REGISTRY) ECR_REGISTRY=$(ECR_REGISTRY) PORT=$(PORT) go run main.go

# Replaces variables in the generic k8s manifest for internal testing
k8s-manifestReplace:
cat manifest.k8s.yml | sed -f .env > used-manifest.k8s.yml

# Generates and adds the TLS secrets for the Ingress Controller to use
k8s-addSecrets: genSelfsigned
kubectl create secret tls ecrreverseproxy --cert ./credentials/cert.pem --key ./credentials/privkey.pem
86 changes: 86 additions & 0 deletions manifest.k8s.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: ecrreverseproxy
data:
PORT: "{PORT}"
REGION: {REGION}
REGISTRY: {REGISTRY}
ECR_REGISTRY: {ECR_REGISTRY}

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: ecrreverseproxy
name: ecrreverseproxy
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
app: ecrreverseproxy
template:
metadata:
labels:
app: ecrreverseproxy
spec:
containers:
- image: marjamis/ecr_reverse_proxy:latest
name: ecrreverseproxy
ports:
- containerPort: {PORT}
protocol: TCP
envFrom:
- configMapRef:
name: ecrreverseproxy
volumes:
- name: certs
secret:
secretName: ecrreverseproxy
---

apiVersion: v1
kind: Service
metadata:
labels:
app: ecrreverseproxy
name: ecrreverseproxy
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: "0.0.0.0/0"
namespace: kube-system
spec:
type: LoadBalancer
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be purely a ClusterIP as this will be used via an Ingress Controller.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also look into restricting outside access completely as this should really only need to be used internally to the cluster.

ports:
- name: http
port: 443
targetPort: {PORT}
protocol: TCP
selector:
app: ecrreverseproxy

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ecrreverseproxy
namespace: kube-system
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: true
nginx.ingress.kubernetes.io/force-ssl-redirect: true
spec:
rules:
- host: {HOST}
http:
paths:
- backend:
serviceName: ecrreverseproxy
servicePort: {PORT}
path: /
tls:
- hosts:
- {HOST}
secretName: ecrreverseproxy