Skip to content

Commit

Permalink
Add installation manifests, and helm chart (#14)
Browse files Browse the repository at this point in the history
* Add OWNERS

* Add OWNERS

* Create charts

* Regenerate static manifests

* Implement suggestions

* Fix crd-init name

* Expand RBAC

* Expand readme
  • Loading branch information
Jakub Błaszczyk authored Aug 26, 2019
1 parent 771e2e9 commit 8015edf
Show file tree
Hide file tree
Showing 28 changed files with 1,474 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ ci-release: build build-image push-image
clean:
rm -rf bin

.PHONY: path-to-referenced-charts
path-to-referenced-charts:
@echo "resources/core"

# Install CRDs into a cluster
install: manifests
kustomize build config/crd | kubectl apply -f -
@if ! kubectl get crd virtualservices.networking.istio.io > /dev/null 2>&1 ; then kubectl apply -f hack/networking.istio.io_virtualservice.yaml; fi;

# Generate static installation files
static: manifests
kustomize build config/default -o install/k8s

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
kustomize build config/default | kubectl apply -f -
Expand Down
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ patchesStrategicMerge:
# Only one of manager_auth_proxy_patch.yaml and
# manager_prometheus_metrics_patch.yaml should be enabled.
#- manager_prometheus_metrics_patch.yaml
- manager_sa_patch.yaml

# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in crd/kustomization.yaml
#- manager_webhook_patch.yaml
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ spec:
template:
spec:
containers:
- image: api-gateway-controller:latest
- image: eu.gcr.io/kyma-project/incubator/develop/api-gateway-controller:1669a1f9
name: manager
imagePullPolicy: IfNotPresent
9 changes: 9 additions & 0 deletions config/default/manager_sa_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
serviceAccountName: api-gateway-sa
10 changes: 7 additions & 3 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ resources:
- role_binding.yaml
- leader_election_role.yaml
- leader_election_role_binding.yaml
- service_account.yaml
# Comment the following 3 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
- auth_proxy_service.yaml
- auth_proxy_role.yaml
- auth_proxy_role_binding.yaml
# - auth_proxy_service.yaml
# - auth_proxy_role.yaml
# - auth_proxy_role_binding.yaml

patchesStrategicMerge:
- patches/role_vs_patch.yaml
4 changes: 2 additions & 2 deletions config/rbac/leader_election_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ roleRef:
name: leader-election-role
subjects:
- kind: ServiceAccount
name: default
namespace: system
name: api-gateway-api-gateway-sa
namespace: api-gateway-system
12 changes: 12 additions & 0 deletions config/rbac/patches/role_vs_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups: ["gateway.kyma-project.io"]
resources: ["gates", "gates/status"]
verbs: ["*"]
- apiGroups: ["networking.istio.io"]
resources: ["virtualservices"]
verbs: ["create", "delete", "get", "patch", "list", "watch"]
4 changes: 2 additions & 2 deletions config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ roleRef:
name: manager-role
subjects:
- kind: ServiceAccount
name: default
namespace: system
name: api-gateway-api-gateway-sa
namespace: api-gateway-system
5 changes: 5 additions & 0 deletions config/rbac/service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: api-gateway-sa
38 changes: 38 additions & 0 deletions install/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Installation guide

This directory contains two methods of installation for the controller.

## Static manifests
The `k8s` directory contains static kubernetes manifests generated by kubebuilder. They can be used to quickly deploy a simple installation of the controller (deployment, RBAC).
To install simply run:

```bash
kubectl apply -f k8s
```

## Helm chart
The `helm` directory contains a helm chart for the Gateway controller. It consists of the following elements:
- CustomResourceDefinition(CRD) managed by a job (for installation and upgrade)
- Controller deployment
- RBAC settings

To install simply run:

```bash
helm install --name gatekeeper --namespace default helm/api-gateway
```

>**NOTE:** This CRD requires and uses the following applications/CRD, which should be installed beforehand:
> - Istio [VirtualService](https://istio.io/docs/reference/config/networking/v1alpha3/virtual-service/)
> - Istio [Policy](https://istio.io/docs/reference/config/istio.authentication.v1alpha1/)
> - Oathkeeper [AccessRule](https://www.ory.sh/docs/oathkeeper/)
> + Oathkeeper CRD resources are available as charts in [this repo](https://github.com/ory/k8s)
## HowTo
Installation example (required tools: `minikube`, `kubectl`, `helm`):
- Create a k8s cluster using minikube (`minikube start --memory=8192 --cpus=4`)
- Installer tiller on the cluster (`helm init`)
- Apply required CRDs (`kubectl apply -f hack/`)
- Install the Gatekeeper chart (`helm install --name gatekeeper --namespace some-namespace install/helm/api-gateway`)
- Create sample resource (`kubectl apply -f config/samples/valid.yaml`)
- Check controller logs (`kubectl logs -n default -lapp.kubernetes.io/name=api-gateway -c api-gateway`)
21 changes: 21 additions & 0 deletions install/helm/api-gateway/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
5 changes: 5 additions & 0 deletions install/helm/api-gateway/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2alpha1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: api-gateway
version: 0.1.0
Loading

0 comments on commit 8015edf

Please sign in to comment.