Skip to content

Instantly share code, notes, and snippets.

@philipz
Last active January 6, 2024 13:50
Show Gist options
  • Save philipz/a25d35232f941531cd58e7bcc88c3bc1 to your computer and use it in GitHub Desktop.
Save philipz/a25d35232f941531cd58e7bcc88c3bc1 to your computer and use it in GitHub Desktop.
Knative in Kind

Knative Quickstart in Kind

Ref: How to set up a local Knative environment with KinD and without DNS headaches

Install kn and kn-quickstart

https://knative.dev/docs/client/install-kn/

https://github.com/knative-extensions/kn-plugin-quickstart

Create Kind Cluster


Copy
cat <<EOF | kind create cluster --name knative --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
    ## expose port 31080 of the node to port 80 on the host
  - containerPort: 31080
    hostPort: 80
    ## expose port 31443 of the node to port 443 on the host
  - containerPort: 31443
    hostPort: 443
EOF

Install Knative by kn-quickstart CLI

kn quickstart kind --registry

Run Go Hello

https://knative.dev/docs/samples/serving/

Use kn CLI

kn service create hello \
--image ghcr.io/knative/helloworld-go:latest \
--port 8080 \
--env TARGET=World

or

Use kubectl CLI

  1. Create hello.yaml
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: hello
spec:
  template:
    spec:
      containers:
        - image: gcr.io/knative-samples/helloworld-go
          ports:
            - containerPort: 8080
          env:
            - name: TARGET
              value: "World"
  1. apply
kubectl apply -f hello.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment