Skip to content

Commit

Permalink
Merge pull request #9 from stefanprodan/deploy
Browse files Browse the repository at this point in the history
Configure Kubernetes deployment
  • Loading branch information
stefanprodan authored Nov 1, 2020
2 parents 30f0f87 + 53d1bb0 commit 2263a2a
Show file tree
Hide file tree
Showing 29 changed files with 109 additions and 380 deletions.
6 changes: 0 additions & 6 deletions .github/actions/kubebuilder/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions .github/actions/kubebuilder/action.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/actions/kubebuilder/entrypoint.sh

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
push:
branches:
- master
- main

jobs:
unit:
Expand All @@ -22,9 +22,9 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
go-version: 1.15.x
- name: Setup Kubebuilder
uses: ./.github/actions/kubebuilder
uses: fluxcd/pkg/actions/kubebuilder@main
- name: Run tests
run: make test
env:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15 as builder
FROM golang:1.15-alpine as builder

WORKDIR /workspace

Expand All @@ -14,7 +14,7 @@ COPY main.go main.go
COPY controllers/ controllers/

# build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-watcher main.go
RUN CGO_ENABLED=0 go build -a -o source-watcher main.go

FROM alpine:3.12

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ uninstall: manifests

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
cd config/manager && kustomize edit set image controller=${IMG}
cd config/manager && kustomize edit set image source-watcher=${IMG}
kustomize build config/default | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=source-reader webhook paths="./..." output:crd:artifacts:config=config/crd/bases

# Run go fmt against code
fmt:
Expand Down
26 changes: 0 additions & 26 deletions config/certmanager/certificate.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions config/certmanager/kustomization.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions config/certmanager/kustomizeconfig.yaml

This file was deleted.

79 changes: 9 additions & 70 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,70 +1,9 @@
# Adds namespace to all resources.
namespace: source-watcher-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: source-watcher-

# Labels to add to all resources and selectors.
#commonLabels:
# someName: someValue

bases:
- ../crd
- ../rbac
- ../manager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- ../webhook
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
#- ../certmanager
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus

patchesStrategicMerge:
# Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line.
- manager_auth_proxy_patch.yaml

# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- manager_webhook_patch.yaml

# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'.
# Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks.
# 'CERTMANAGER' needs to be enabled to use ca injection
#- webhookcainjection_patch.yaml

# the following config is for teaching kustomize how to do var substitution
vars:
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
# objref:
# kind: Certificate
# group: cert-manager.io
# version: v1alpha2
# name: serving-cert # this name should match the one in certificate.yaml
# fieldref:
# fieldpath: metadata.namespace
#- name: CERTIFICATE_NAME
# objref:
# kind: Certificate
# group: cert-manager.io
# version: v1alpha2
# name: serving-cert # this name should match the one in certificate.yaml
#- name: SERVICE_NAMESPACE # namespace of the service
# objref:
# kind: Service
# version: v1
# name: webhook-service
# fieldref:
# fieldpath: metadata.namespace
#- name: SERVICE_NAME
# objref:
# kind: Service
# version: v1
# name: webhook-service
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: source-system
resources:
- ../rbac
- ../manager
- github.com/fluxcd/source-controller/config//crd?ref=v0.2.0
- github.com/fluxcd/source-controller/config//manager?ref=v0.2.0
- namespace.yaml
25 changes: 0 additions & 25 deletions config/default/manager_auth_proxy_patch.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions config/default/manager_webhook_patch.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions config/default/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
control-plane: controller
name: source-system
15 changes: 0 additions & 15 deletions config/default/webhookcainjection_patch.yaml

This file was deleted.

61 changes: 61 additions & 0 deletions config/manager/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: source-watcher
labels:
control-plane: controller
spec:
selector:
matchLabels:
app: source-watcher
replicas: 1
template:
metadata:
labels:
app: source-watcher
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
spec:
terminationGracePeriodSeconds: 10
containers:
- name: manager
image: source-watcher
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
ports:
- containerPort: 8080
name: http-prom
env:
- name: RUNTIME_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
args:
- --log-level=info
- --log-json
- --enable-leader-election
livenessProbe:
httpGet:
port: http
path: /
readinessProbe:
httpGet:
port: http
path: /
resources:
limits:
cpu: 1000m
memory: 1Gi
requests:
cpu: 50m
memory: 64Mi
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}

8 changes: 7 additions & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- manager.yaml
- deployment.yaml
images:
- name: source-watcher
newName: source-watcher
newTag: v0.2.0
Loading

0 comments on commit 2263a2a

Please sign in to comment.