Knative installation
Minikube
Container Runtime
# podman does not work!!!, use docker instead
# sudo apt-get -y install podman
source /etc/os-release
echo $UBUNTU_CODENAME
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$UBUNTU_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
# use this if docker group is not present:
# newgrp docker
# groups
See:
Install Minikube
Mac:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-arm64
sudo install minikube-darwin-arm64 /usr/local/bin/minikube
Ubuntu:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube config set rootless true
Start Minikube
If use docker:
# Ubuntu:
# sudo usermod -aG docker $USER && newgrp docker
minikube start --cpus=4 --memory=4096 --addons=ingress --kubernetes-version=1.28.3 --insecure-registry "10.0.0.0/24"
For podman(does not work):
sudo chmod +w /etc/sudoers
# add this line to the END of the file
riguz ALL=(ALL) NOPASSWD: ALL
sudo chmod -w /etc/sudoers
# To test:
# sudo -n -k podman version
minikube start --cpus=4 --memory=4096 --addons=ingress --container-runtime=containerd
Install Kubectl(Ubuntu):
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Knative
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.13.1/serving-crds.yaml
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.13.1/serving-core.yaml
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.13.2/eventing-crds.yaml
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.13.2/eventing-core.yaml
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.13.2/in-memory-channel.yaml
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.13.2/mt-channel-broker.yaml
kubectl apply -f https://github.com/knative-extensions/eventing-kafka-broker/releases/download/knative-v1.13.4/eventing-kafka-controller.yaml
kubectl apply -f https://github.com/knative-extensions/eventing-kafka-broker/releases/download/knative-v1.13.4/eventing-kafka-broker.yaml
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.13.0/kourier.yaml
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}'
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.13.1/serving-default-domain.yaml
kubectl --namespace kourier-system get service kourier
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
AGE
kourier LoadBalancer 10.45.2.31 35.192.171.57 80:32515/TCP,443:31010/TCP 4m31s
Dump images:
https://github.com/knative/serving/releases/download/knative-v1.13.1/serving-crds.yaml
https://github.com/knative/serving/releases/download/knative-v1.13.1/serving-core.yaml
https://github.com/knative/eventing/releases/download/knative-v1.13.2/eventing-crds.yaml
https://github.com/knative/eventing/releases/download/knative-v1.13.2/eventing-core.yaml
https://github.com/knative/eventing/releases/download/knative-v1.13.2/in-memory-channel.yaml
https://github.com/knative/eventing/releases/download/knative-v1.13.2/mt-channel-broker.yaml
https://github.com/knative-extensions/eventing-kafka-broker/releases/download/knative-v1.13.4/eventing-kafka-controller.yaml
https://github.com/knative-extensions/eventing-kafka-broker/releases/download/knative-v1.13.4/eventing-kafka-broker.yaml
https://github.com/knative/net-kourier/releases/download/knative-v1.13.0/kourier.yaml
https://github.com/knative/serving/releases/download/knative-v1.13.1/serving-default-domain.yaml
import csv
import urllib.request
import re
import os
import requests
import json
import subprocess
class ReleseFileTransformer:
def transform(self, remote_url):
images = list(self.read_and_process_from_url(remote_url))
return images
def read_and_process_from_url(self, url):
images = []
for line in urllib.request.urlopen(url):
text = line.decode('utf-8')
images.extend(list(self.process_release_file_line(text)))
return images
def find_image_names(self, line):
gcrimages = self.find_image_names_by_prefix(r'gcr\.io', line)
cgrimages = self.find_image_names_by_prefix(r'cgr\.dev', line)
return gcrimages + cgrimages
def find_image_names_by_prefix(self, prefix, line):
pattern = prefix + r'(?:/[a-z-_\.]+)+(?::v?\d+(?:\.\d+)*)?(?:@sha256:[a-f0-9]{64})?'
return re.findall(pattern, line)
def process_release_file_line(self, text):
if text.lstrip().rstrip().startswith('#'):
return text
replaced_text = text
for image in self.find_image_names(text):
yield image
def save_result(self, lines, output_file):
with open(output_file, 'w') as file:
file.writelines(lines)
def next_release_file():
with open('releases.txt') as file:
for line in file.readlines():
line = line.lstrip().rstrip()
if not line.startswith('#') and not line == '':
yield line
def main():
print('Parsing images...')
# used by kourier
all_images = ['docker.io/envoyproxy/envoy:v1.26-latest']
release_transformer = ReleseFileTransformer()
for url in next_release_file():
print('>> ' + url)
images = release_transformer.transform(url)
all_images.extend(images)
unique_images = set(all_images)
pull_commands = '\n'.join(map(lambda i: 'sudo ctr images pull ' + i, unique_images))
print(pull_commands)
export_command = 'sudo ctr images export knative-1.13.tar ' + ' '.join(unique_images)
print(export_command)
if __name__ == '__main__':
main()
sudo ctr images pull docker.io/envoyproxy/envoy:v1.26-latest sudo ctr images pull gcr.io/knative-releases/knative.dev/serving/cmd/webhook@sha256:700c69915dc7cd86dffb61c26b0ba34427fab809de1e3344589dd955b6440882 sudo ctr images pull gcr.io/knative-releases/knative.dev/serving/cmd/default-domain@sha256:0a9bf78e49c9de18a9737d4e8fa95c3f44963c5b5f720e518c3714a21c5443a1 sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/webhook@sha256:895e6c23e85e604f8bce81d94fcaf549dd9c8c0b2a9b3403140111fc3f5cc4c0 sudo ctr images pull gcr.io/knative-releases/knative.dev/serving/cmd/activator@sha256:21f8e11a44bf1e260602d30e6762a3dc433c608d1dd0e309c0ff89728e71901d sudo ctr images pull gcr.io/knative-releases/knative-kafka-broker-receiver@sha256:db44cd0c48c0b197755519b39f531a7dedec0c97ada606dad9fc1db6485978a5 sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/broker/ingress@sha256:efcc460709a3cbb102d9ba4b67b356365b326ffddc7469dca41a0caaefe8bb27 sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/in_memory/channel_dispatcher@sha256:a663cf6958b18fbe92161e063c95a76be660b1006eff91a8f77c4ee1e013bdb1 sudo ctr images pull gcr.io/knative-releases/knative.dev/serving/cmd/controller@sha256:53d9aa4d2c7a82f5a01202e386f7503b21839cbe2e5e62f1e9bda2aa5f11b518 sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/controller@sha256:303c42f67639f1670d4186a4b18c072d855da89188fa3f7c3227b84f31a1343c sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/in_memory/channel_controller@sha256:3e2c83f66a004d02394daafb73fc2cf1d36789a7e6d476ec45daa631e649b3a9 sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/broker/filter@sha256:16b749f4a4af03e2b9ad41e456346539e723ed3050dba8cc6d912f5709d739b6 sudo ctr images pull gcr.io/knative-releases/knative.dev/net-kourier/cmd/kourier@sha256:75d8a96922bb407f026ca49ceb72d51d51abbbde787351ce73c7b75737c9a0df sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/apiserver_receive_adapter@sha256:5a19b169e30255d6bf2b7e8946742cf200b5380018fa9e2ca1a8a2a4e5a07ef8 sudo ctr images pull gcr.io/knative-releases/knative.dev/serving/cmd/queue@sha256:e52286fc4843470383e917abc9c1b0c8d10f585c4274c57b612279869bc86f0d sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing-kafka-broker/control-plane/cmd/kafka-controller@sha256:3fbcbcef103211976cfc1d0739a0885969296a9aff6ee9b18e830c261347438e sudo ctr images pull gcr.io/knative-releases/knative.dev/serving/cmd/autoscaler@sha256:34796e9f760bb67065c6f101296513b38d04d39d11888e919692ac46fa6dc7c2 sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/mtchannel_broker@sha256:275a793b9b46ed51511197ef5a05f5bf165b10f22d09cfdb71e40e478b0059df sudo ctr images pull gcr.io/knative-releases/knative-kafka-broker-dispatcher@sha256:68d8086222413d3cc1d5dea7686b9de8603edb211f570f4dad7f53d0f7c53a5f sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing/cmd/mtping@sha256:63812c5f4b4c6c51470f7934da25e6eb91a902e5c427dbf42bd49fe643182e3f sudo ctr images pull gcr.io/knative-releases/knative.dev/eventing-kafka-broker/control-plane/cmd/webhook-kafka@sha256:92039e70de6c64eefbd023147213749198f6e0f814d36cb2311a298e361cae02
sudo ctr images export knative-1.13.tar docker.io/envoyproxy/envoy:v1.26-latest gcr.io/knative-releases/knative.dev/serving/cmd/webhook@sha256:700c69915dc7cd86dffb61c26b0ba34427fab809de1e3344589dd955b6440882 gcr.io/knative-releases/knative.dev/serving/cmd/default-domain@sha256:0a9bf78e49c9de18a9737d4e8fa95c3f44963c5b5f720e518c3714a21c5443a1 gcr.io/knative-releases/knative.dev/eventing/cmd/webhook@sha256:895e6c23e85e604f8bce81d94fcaf549dd9c8c0b2a9b3403140111fc3f5cc4c0 gcr.io/knative-releases/knative.dev/serving/cmd/activator@sha256:21f8e11a44bf1e260602d30e6762a3dc433c608d1dd0e309c0ff89728e71901d gcr.io/knative-releases/knative-kafka-broker-receiver@sha256:db44cd0c48c0b197755519b39f531a7dedec0c97ada606dad9fc1db6485978a5 gcr.io/knative-releases/knative.dev/eventing/cmd/broker/ingress@sha256:efcc460709a3cbb102d9ba4b67b356365b326ffddc7469dca41a0caaefe8bb27 gcr.io/knative-releases/knative.dev/eventing/cmd/in_memory/channel_dispatcher@sha256:a663cf6958b18fbe92161e063c95a76be660b1006eff91a8f77c4ee1e013bdb1 gcr.io/knative-releases/knative.dev/serving/cmd/controller@sha256:53d9aa4d2c7a82f5a01202e386f7503b21839cbe2e5e62f1e9bda2aa5f11b518 gcr.io/knative-releases/knative.dev/eventing/cmd/controller@sha256:303c42f67639f1670d4186a4b18c072d855da89188fa3f7c3227b84f31a1343c gcr.io/knative-releases/knative.dev/eventing/cmd/in_memory/channel_controller@sha256:3e2c83f66a004d02394daafb73fc2cf1d36789a7e6d476ec45daa631e649b3a9 gcr.io/knative-releases/knative.dev/eventing/cmd/broker/filter@sha256:16b749f4a4af03e2b9ad41e456346539e723ed3050dba8cc6d912f5709d739b6 gcr.io/knative-releases/knative.dev/net-kourier/cmd/kourier@sha256:75d8a96922bb407f026ca49ceb72d51d51abbbde787351ce73c7b75737c9a0df gcr.io/knative-releases/knative.dev/eventing/cmd/apiserver_receive_adapter@sha256:5a19b169e30255d6bf2b7e8946742cf200b5380018fa9e2ca1a8a2a4e5a07ef8 gcr.io/knative-releases/knative.dev/serving/cmd/queue@sha256:e52286fc4843470383e917abc9c1b0c8d10f585c4274c57b612279869bc86f0d gcr.io/knative-releases/knative.dev/eventing-kafka-broker/control-plane/cmd/kafka-controller@sha256:3fbcbcef103211976cfc1d0739a0885969296a9aff6ee9b18e830c261347438e gcr.io/knative-releases/knative.dev/serving/cmd/autoscaler@sha256:34796e9f760bb67065c6f101296513b38d04d39d11888e919692ac46fa6dc7c2 gcr.io/knative-releases/knative.dev/eventing/cmd/mtchannel_broker@sha256:275a793b9b46ed51511197ef5a05f5bf165b10f22d09cfdb71e40e478b0059df gcr.io/knative-releases/knative-kafka-broker-dispatcher@sha256:68d8086222413d3cc1d5dea7686b9de8603edb211f570f4dad7f53d0f7c53a5f gcr.io/knative-releases/knative.dev/eventing/cmd/mtping@sha256:63812c5f4b4c6c51470f7934da25e6eb91a902e5c427dbf42bd49fe643182e3f gcr.io/knative-releases/knative.dev/eventing-kafka-broker/control-plane/cmd/webhook-kafka@sha256:92039e70de6c64eefbd023147213749198f6e0f814d36cb2311a298e361cae02
CLI
wget https://github.com/knative/client/releases/download/knative-v1.11.0/kn-darwin-arm64
sudo install kn-darwin-arm64 /usr/local/bin/kn
wget https://github.com/knative/func/releases/download/knative-v1.11.0/func_darwin_arm64
sudo install func_darwin_arm64 /usr/local/bin/func
# for ubuntu
wget https://github.com/knative/client/releases/download/knative-v1.13.0/kn-linux-amd64
wget https://github.com/knative/func/releases/download/knative-v1.12.1/func_linux_amd64
sudo install kn-linux-amd64 /usr/local/bin/kn
sudo install func_linux_amd64 /usr/local/bin/func
Post settings
minikube tunnel
minikube addons enable registry
kubectl port-forward --namespace kube-system service/registry 5000:80
docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:$(minikube ip):5000"
kubectl -n knative-serving edit configmap config-deployment
# add
data:
registries-skipping-tag-resolving: "localhost:5000"
Test create func
func create -l node helloworld
cd helloworld
func build
> localhost:5000/helloworld
$ func build
A registry for function images is required. For example, 'docker.io/tigerteam'.
? Registry for function images: localhost:5000/helloworld
Note: building a function the first time will take longer than subsequent builds
🙌 Function built: localhost:5000/helloworld/helloworld:latest
$ func deploy
function up-to-date. Force rebuild with --build
✅ Function deployed in namespace "default" and exposed at URL:
http://helloworld.default.127.0.0.1.sslip.io
Access from host network
kubectl port-forward --namespace kourier-system service/kourier 8080:80 --address 0.0.0.0
sudo ufw enable 8080
Then, access the service:
curl -H "Host: helloworld.default.10.111.190.244.sslip.io" http://10.226.21.75:8080
Tekton (Not Required)
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.56.2/release.yaml
kubectl apply -f https://storage.googleapis.com/tekton-releases/triggers/previous/v0.26.1/release.yaml
kubectl apply -f https://storage.googleapis.com/tekton-releases/triggers/previous/v0.26.1/interceptors.yaml
kubectl apply -f https://github.com/tektoncd/dashboard/releases/download/v0.45.0/release-full.yaml
kubectl port-forward -n tekton-pipelines service/tekton-dashboard 9097:9097
*.func.riguz.com 35.192.171.57
kubectl patch configmap/config-domain \
--namespace knative-serving \
--type merge \
--patch '{"data":{"func.riguz.com":""}}'