Tuesday, November 03, 2020

temporary notes on kind with knative: (not working yet)

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
$ sudo apt update
$ sudo apt install docker-ce


$ sudo usermod -aG docker ${USER}
$ su - ${USER}
$ id -nG

$ curl -OL https://golang.org/dl/go1.15.3.linux-amd64.tar.gz
$ sudo tar -C /usr/local -xzf go1.14.3.linux-amd64.tar.gz
$ export PATH=$PATH:/usr/local/go/bin
$ mkdir -p $HOME/gosrc
$ export GOPATH=$HOME/gosrc

$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$ echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
$ sudo apt-get update
$ sudo apt-get install -y kubectl

$ GO111MODULE="on" go get sigs.k8s.io/kind@v0.9.0
$ kind create cluster

$ kubectl apply -f https://github.com/knative/serving/releases/download/v0.18.0/serving-crds.yaml
$ kubectl apply -f https://github.com/knative/serving/releases/download/v0.18.0/serving-core.yaml
$ kubectl apply -f https://github.com/knative/serving/releases/download/v0.18.0/serving-default-domain.yaml

$ kubectl apply -f https://github.com/knative/net-kourier/releases/download/v0.18.0/kourier.yaml
$ kubectl patch configmap/config-network -n knative-serving --type merge -p '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}'

$ kubectl get configmap kube-proxy -n kube-system -o yaml | sed -e "s/strictARP: false/strictARP: true/" | kubectl apply -f - -n kube-system

$ kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.9.4/manifests/namespace.yaml
$ kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
$ kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.9.4/manifests/metallb.yaml

Thursday, November 05, 2020

the above knative experiment is failed, couldn't route traffic to the loadbalancer

however it's still useful, inside vagrant:

(kind-cluster.yml)

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  • role: control-plane kubeadmConfigPatches: - | kind: InitConfiguration nodeRegistration: kubeletExtraArgs: node-labels: "ingress-ready=true" extraPortMappings: - containerPort: 80 hostPort: 80 protocol: TCP - containerPort: 443 hostPort: 443 protocol: TCP containerdConfigPatches: - |- [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5000"] endpoint = ["http://kind-registry:5000"]

create cluster with $ kind create cluster –config kind-cluster.yml

then create nginx ingress

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml

start local registry

$ docker run -d -p 5000:5000 --name kind-registry --restart always -v /vagrant/registry_data:/var/lib/registry registry:2

apply config map

apiVersion: v1
kind: ConfigMap
metadata:
  name: local-registry-hosting
  namespace: kube-public
data:
  localRegistryHosting.v1: |
    host: "localhost:5000"
    help: "https://kind.sigs.k8s.io/docs/user/local-registry/"

then can build and push image to local registry:

$ docker image build -t localhost:5000/nodeapp .
$ docker image push localhost:5000/nodeapp

and start the app

kind: Pod
apiVersion: v1
metadata:
  name: nodeapp
  labels:
    app: nodeapp
spec:
  containers:
  • name: nodeapp image: localhost:5000/nodeapp --- kind: Service apiVersion: v1 metadata: name: nodeapp spec: selector: app: nodeapp ports: - port: 8080 --- kind: Ingress apiVersion: networking.k8s.io/v1beta1 metadata: name: nodeapp-ingress spec: rules: - http: paths: - path: /nodeapp backend: serviceName: nodeapp servicePort: 8080

then can visit the app within vagrant or on the host as well

Saturday, November 07, 2020

a very useful tool: tomnomnom/gron: Make JSON greppable


a quick read and found something I didn't know: Vi Essentials

Tuesday, November 10, 2020

kind is k8s in a container, k3d is even more lightweight, k3s in a container

the setup is easy, and I'm also no problem with traefik as ingress

but seems local registry is not quite ready on v3 yet, needs to manually mount the config file:

$HOME/.k3d/registries.yaml:

mirrors:
  "registry.localhost:5000":
    endpoint:
  • "http://registry.localhost:5000"

start the local registry:

$ docker volume create local_registry
$ docker container run -d --name registry.localhost -v local_registry:/var/lib/registry --restart always -p 5000:5000 registry:2

add to /etc/hosts if registry.localhost can't be resolved.

start the cluster with (also expose 80 port to host):

$ k3d cluster create -p "80:80@loadbalancer" --volume $HOME/.k3d/registries.yaml:/etc/rancher/k3s/registries.yaml


A tiny CI system built with bash, git and redis

found this while looking for gin articles, looks interesting:

Clean Boilerplate of Go, Domain-Driven Design, Clean Architecture, Gin and GORM

also A quick introduction to clean architecture

Friday, November 13, 2020

picking up shadow-cljs

$ lein new shadow-cljs myapp +reagent

and following ClojureTO/JS-Workshop: Reagent Workshop for React developers

Saturday, November 14, 2020

reading this free book: Fulcro Developers Guide

Sunday, November 22, 2020

some links for practicing numpy and pandas


Blog Archives

Search Blog: