runtime

module
v0.0.0-...-d51a12e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2019 License: Apache-2.0

README

Deprecated: It has been migrated to Kyma

Runtime

Requirements & Scaffolding

The code got scaffolded with kubebuilder==1.0.8. Make sure to use kustomize==1.0.10. Otherwise you will get security errors.

The code has been scaffoled using the following commands:

kubebuilder init --domain kyma-project.io
kubebuilder create api --group runtime --version v1alpha1 --kind Function
kubebuilder alpha webhook --group runtime --version v1alpha1 --kind Function --type mutating

WebHook Readme

The following section shows some links on webhooks and how the webhook mutates and validates the example functions.

Alternative

Custom Resource Validation Schema

Examples
Mutation

Deploy Function:

kubectl apply -f config/samples/runtime_v1alpha1_function.yaml

Verify default values got set:

$ kubectl get functions.runtime.kyma-project.io function-sample -oyaml
...
spec:
  function: |
    module.exports = {
        main: function(event, context) {
          return 'Hello World'
        }
      }
  functionContentType: plaintext
  runtime: nodejs8
  size: S
  timeout: 180
Validation

Deploy Function:

$ kubectl apply -f config/samples/runtime_v1alpha1_function_invalid.yaml
Error from server (InternalError): error when creating "config/samples/runtime_v1alpha1_function_invalid.yaml": Internal error occurred: admission webhook "mutating-create-function.kyma-project.io" denied the request: runtime should be one of 'nodejs6,nodejs8'

Development

Test
make test
Setup knative

start a beefy minikube

minikube start \
  --memory=12288 \
  --cpus=4 \
  --kubernetes-version=v1.12.0 \
  --vm-driver=hyperkit \
  --disk-size=30g \
  --extra-config=apiserver.enable-admission-plugins="LimitRanger,NamespaceExists,NamespaceLifecycle,ResourceQuota,ServiceAccount,DefaultStorageClass,MutatingAdmissionWebhook"

install istio

kubectl apply \
  --filename https://raw.githubusercontent.com/knative/serving/v0.5.2/third_party/istio-1.0.7/istio-crds.yaml &&
curl -L https://raw.githubusercontent.com/knative/serving/v0.5.2/third_party/istio-1.0.7/istio.yaml \
  | sed 's/LoadBalancer/NodePort/' \
  | kubectl apply --filename -

install knative

kubectl apply --selector knative.dev/crd-install=true \
--filename https://github.com/knative/serving/releases/download/v0.6.1/serving.yaml \
--filename https://github.com/knative/build/releases/download/v0.6.0/build.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.6.1/release.yaml \
--filename https://github.com/knative/eventing-sources/releases/download/v0.6.0/eventing-sources.yaml \
--filename https://github.com/knative/serving/releases/download/v0.6.1/monitoring.yaml \
--filename https://raw.githubusercontent.com/knative/serving/v0.6.1/third_party/config/build/clusterrole.yaml

install knative part2

kubectl apply --filename https://github.com/knative/serving/releases/download/v0.6.0/serving.yaml --selector networking.knative.dev/certificate-provider!=cert-manager \
   --filename https://github.com/knative/build/releases/download/v0.6.0/build.yaml \
   --filename https://github.com/knative/eventing/releases/download/v0.6.0/release.yaml \
   --filename https://github.com/knative/eventing-sources/releases/download/v0.6.0/eventing-sources.yaml \
   --filename https://github.com/knative/serving/releases/download/v0.6.0/monitoring.yaml \
   --filename https://raw.githubusercontent.com/knative/serving/v0.6.0/third_party/config/build/clusterrole.yaml
Local Deployment
Manager running locally

modify config/config.yaml to include your docker.io credentials (base64 encoded) and update the docker registry value to your docker.io username

Apply the configuration

kubectl apply -f config/config.yaml

Install the CRD to a local Kubernetes cluster:

make install

Run the controller on your machine:

make run
Manager running inside k8s cluster

This workflow needs to be used until Come up with webhook developer workflow to test it locally #400 is fixed.

eval $(minikube docker-env)
make docker-build
make install
make deploy
Prod Deployment

Uncomment manager_image_patch_dev in kustomization.yaml Then run the following commands:

make install
make docker-push IMG=<e.g. index.docker.io/nachtmaar/runtime-controller>
make deploy
Run the examples

Create sample function

kubectl apply -f config/samples/runtime_v1alpha1_function.yaml -n {NAMESPACE}

search for function

kubectl get functions -n {NAMESPACE}
kubectl get function -n {NAMESPACE}
kubectl get fcn -n {NAMESPACE}

access the function

	curl -v -H "Host: $(kubectl get ksvc sample --output 'jsonpath={.status.domain}' -n {NAMESPACE}" http://$(minikube ip):$(kubectl get svc istio-ingressgateway --namespace istio-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')

Directories

Path Synopsis
cmd
pkg
apis
Package apis contains Kubernetes API groups.
Package apis contains Kubernetes API groups.
apis/runtime
Package runtime contains runtime API versions
Package runtime contains runtime API versions
apis/runtime/v1alpha1
Package v1alpha1 contains API Schema definitions for the runtime v1alpha1 API group +k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:conversion-gen=github.com/kyma-incubator/runtime/pkg/apis/runtime +k8s:defaulter-gen=TypeMeta +groupName=runtime.kyma-project.io
Package v1alpha1 contains API Schema definitions for the runtime v1alpha1 API group +k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:conversion-gen=github.com/kyma-incubator/runtime/pkg/apis/runtime +k8s:defaulter-gen=TypeMeta +groupName=runtime.kyma-project.io

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL