-
-
Save vfarcic/d715c251f851cf28b863ad5414de7de0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/d715c251f851cf28b863ad5414de7de0 | |
########################################################################## | |
# Knative Functions - No Dockerfile, No Lock-In, No Kubernetes Knowledge # | |
# https://youtu.be/VjI5WDOhAwk # | |
########################################################################## | |
# Additional Info: | |
# - Knative Functions: https://github.com/knative/func | |
# - Serverless Computing With Knative And Containers As A Service (CaaS): https://youtu.be/8vrLEbwSu7U | |
# - Container (Docker) Images Without Dockerfile With Buildpacks and kpack: https://youtu.be/fbSoKu8NGSU | |
######### | |
# Setup # | |
######### | |
# Create a Kubernetes cluster. | |
# The Gist has been tested with a "real" Kubernetes cluster. | |
# If you are using a local cluster (e.g., Docker Desktop, Minikube, Rancher Desktop, etc.), you might need to modify some of the commands and manifests. | |
# Install the `kn` CLI from https://knative.dev/docs/getting-started/quickstart-install/#install-the-knative-cli | |
# Install the `func` CLI from https://knative.dev/docs/functions/install-func/#installing-the-func-cli | |
kubectl apply \ | |
--filename https://github.com/knative/serving/releases/download/knative-v1.8.0/serving-crds.yaml | |
kubectl apply \ | |
--filename https://github.com/knative/serving/releases/download/knative-v1.8.0/serving-core.yaml | |
kubectl --namespace knative-serving get pods | |
# Wait until all the Pods are in the "Running" state. | |
kubectl apply \ | |
--filename https://github.com/knative/net-kourier/releases/download/knative-v1.8.0/kourier.yaml | |
kubectl --namespace kourier-system get pods | |
# Wait until all the Pods are in the "Running" state. | |
kubectl --namespace knative-serving \ | |
patch configmap config-network \ | |
--type merge \ | |
--patch '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}' | |
kubectl apply \ | |
--filename https://github.com/knative/serving/releases/download/knative-v1.8.0/serving-default-domain.yaml | |
kubectl apply \ | |
--filename https://github.com/knative/eventing/releases/download/knative-v1.8.0/eventing-crds.yaml | |
kubectl apply \ | |
--filename https://github.com/knative/eventing/releases/download/knative-v1.8.0/eventing-core.yaml | |
# Change `docker.io/vfarcic` with the address of the container registry you'd like to use | |
export CONTAINER_REGISTRY=docker.io/vfarcic | |
kubectl create namespace production | |
# Make sure that Docker or Podman are installed. | |
# If using Podman, make sure that the CLI is aliased as `docker`. | |
################################################# | |
# Self-Managed Functions With Knative Functions # | |
################################################# | |
func create --language go knative-functions-demo | |
cd knative-functions-demo | |
cat func.yaml | |
ls -1 | |
cat handle.go | |
func run --build --registry $CONTAINER_REGISTRY | |
# Open `http://localhost:8080` in a browser | |
# ctrl+c | |
func build --image $CONTAINER_REGISTRY/silly-demo-knf | |
docker image ls | |
func --namespace production deploy | |
# Open the address from the output | |
func --namespace production invoke | |
func --namespace production list | |
kubectl --namespace production get all | |
func --namespace production info | |
func --namespace production delete | |
########### | |
# Destroy # | |
########### | |
cd .. | |
rm -rf knative-functions-demo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment