Skip to content

Instantly share code, notes, and snippets.

@bttnns
Last active November 4, 2020 18:00
Show Gist options
  • Select an option

  • Save bttnns/b0629c5d7e6ebe823bcf7caaf2530a38 to your computer and use it in GitHub Desktop.

Select an option

Save bttnns/b0629c5d7e6ebe823bcf7caaf2530a38 to your computer and use it in GitHub Desktop.
Bring your Functions at ease to the power of Kubernetes

Eclipse Che > Serverless.com > Knative > Minikube with OLM

Install minikube

minikube start --cpus=10 --memory='15g'

Install Operator Lifecycle Manager

curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.17.0/install.sh | bash -s v0.17.0

Install Knative

https://operatorhub.io/operator/knative-operator

kubectl create -f https://operatorhub.io/install/knative-operator.yaml

kubectl get csv -n operators

Wait untill install Succeeded.

Knative Serving

kubectl create ns knative-serving

cat << EOF | kubectl apply -f -
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: knative-serving
  namespace: knative-serving
spec: {}
EOF

Knative Eventing

kubectl create ns knative-eventing

cat << EOF | kubectl apply -f -
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeEventing
metadata:
  name: knative-eventing
  namespace: knative-eventing
spec: {}
EOF

Install Eclipse Che

https://operatorhub.io/operator/eclipse-che

kubectl create -f https://operatorhub.io/install/eclipse-che.yaml

kubectl get csv -n my-eclipse-che

Deploy Eclipse Che

https://github.com/che-incubator/chectl

./chectl server:deploy --installer=olm -n che --olm-channel=stable --platform=minikube

Login to Che and launch new Workspace with Devfile

https://github.com/openshift-labs/serverless-devfile

Import Devfile from URL: https://raw.githubusercontent.com/openshift-labs/serverless-devfile/master/devfile.yaml

Service account

Create the service account

cat << EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
  name: sls-service-account
  namespace: che
EOF

Give cluster admin

cat << EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: sls-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: sls-service-account
  namespace: che
EOF

Get a service account token

kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='sls-service-account')].data.token}"|base64 --decode

Configure .env file

KUBERNETES_ENDPOINT=https://#this needs to be public
KUBERNETES_PORT=6443
KUBERNETES_SERVICE_ACCOUNT_TOKEN=
KUBERNETES_SKIP_TLS_VERIFY=true
DOCKER_USERNAME=#docker hub credentials
DOCKER_PASSWORD=

Create an sls access key

https://app.serverless.com/

generate a key at org/access keys

Demo

  • sls deploy in che and test
  • edit hello world
  • sls deploy and test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment