Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ko for function-controller development deployment #5613

Merged
merged 18 commits into from Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 13 additions & 10 deletions components/function-controller/Makefile
Expand Up @@ -68,7 +68,7 @@ install:

# Uninstall CRDs from cluster
uninstall:
kubectl apply -f config/crds/serverless_v1alpha1_function.yaml
kubectl delete -f config/crds/serverless_v1alpha1_function.yaml

# Generate manifests e.g. CRD, RBAC etc.
manifests:
Expand All @@ -81,16 +81,14 @@ ifeq ($(shell uname -s),Darwin)
sedbackupflag +=
endif

deploy: manifests install bin/kustomize
@echo "updating kustomize image patch file for manager resource"
cp ./config/default/manager_image_patch.yaml{,.bak}
sed $(sedbackupflag)'' -e 's@image: .*@image: $(IMG)@' ./config/default/manager_image_patch.yaml
bin/kustomize build config/default | kubectl apply -f -
mv ./config/default/manager_image_patch.yaml{.bak,}
deploy: manifests install bin/kustomize ko
bin/kustomize build config/default | ko apply -f -
antoineco marked this conversation as resolved.
Show resolved Hide resolved

removewebhook:
-kubectl delete mutatingwebhookconfigurations.admissionregistration.k8s.io function-webhook.serverless.kyma-project.io

undeploy: uninstall bin/kustomize
kubectl delete -f config/crds
bin/kustomize build config/default | kubectl delete -f -
undeploy: uninstall removewebhook bin/kustomize ko
bin/kustomize build config/default | ko delete -f -

# Build the docker image
.PHONY: docker-build
Expand Down Expand Up @@ -127,3 +125,8 @@ export GOBIN := $(GOPATH)/src/$(PKG)/bin
.PHONY: bin/kustomize
bin/kustomize:
@go install ./vendor/sigs.k8s.io/kustomize

.PHONY: ko
ko:
@go get -u github.com/google/ko/cmd/ko

35 changes: 25 additions & 10 deletions components/function-controller/README.md
Expand Up @@ -44,7 +44,6 @@ Follow these steps to prepare the environment you will use to deploy the Control

```bash
cat <<EOF | kubectl -n serverless-system apply -f -
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -57,6 +56,18 @@ Follow these steps to prepare the environment you will use to deploy the Control
dockerFileName: dockerfile-nodejs-8
- ID: nodejs6
dockerFileName: dockerfile-nodejs-6
funcSizes: |
- size: S
- size: M
- size: L
funcTypes: |
- type: plaintext
- type: base64
defaults: |
size: S
runtime: nodejs8
timeOut: 180
funcContentType: plaintext
EOF
```

Expand Down Expand Up @@ -102,18 +113,22 @@ Follow these steps to prepare the environment you will use to deploy the Control

### Deploy the controller

1. Use the `make` targets to build the Function Controller image, tag it to the value of the **IMG** environment variable, and push it to the remote container registry.
Copy link
Contributor

Choose a reason for hiding this comment

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

IMG can also be removed in the intro.

To deploy the Function Controller to the `serverless-system` Namespace, run:

```bash
make docker-build
make docker-push
```
```bash
make deploy
```

2. After the image has been successfully pushed, deploy the Function Controller to the `serverless-system` Namespace.
This runs [ko](https://github.com/google/ko) to build your image and push it to your configured docker repository.

```bash
make deploy
```
>**NOTE:** Make sure the **KO_DOCKER_REPO** environment variable points to a valid docker repository.
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of that isolated note, I think it would be helpful to have the env var described together with the other env vars at the top.

Copy link
Contributor

Choose a reason for hiding this comment

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

docker->Docker

>```bash
>#for hub.docker.io
>export KO_DOCKER_REPO=<your dockerhub username>
>
>#to use your local docker daemon and its image store
>export KO_DOCKER_REPO=ko.local
>```

## Usage

Expand Down
Expand Up @@ -18,5 +18,4 @@ spec:
containers:
- name: manager
# image and tag get replaced by 'make docker-build'
image: function-controller:latest
imagePullPolicy: Always
4 changes: 1 addition & 3 deletions components/function-controller/config/manager/manager.yaml
Expand Up @@ -35,9 +35,7 @@ spec:
controller-tools.k8s.io: "1.0"
spec:
containers:
- command:
- /manager
image: ""
- image: github.com/kyma-project/kyma/components/function-controller/cmd/manager
imagePullPolicy: Always
name: manager
env:
Expand Down