Skip to content

Instantly share code, notes, and snippets.

@feczo
Last active September 28, 2021 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feczo/6072a638be7ff03f6c479ef990a1f35c to your computer and use it in GitHub Desktop.
Save feczo/6072a638be7ff03f6c479ef990a1f35c to your computer and use it in GitHub Desktop.

Base K8 setup

export KUBERNETES_SKIP_CREATE_CLUSTER = 1
curl -sS https://get.k8s.io | bash

change machine type, region and number of worker nodes enable pre-emptible machine type to reduce cost requesting more external IP in region quota (IN_USE_ADDRESSES) on console.cloud.google.com

vi kubernetes/cluster/gce/config-default.sh
kubernetes/cluster/kube-up.sh
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
kubectl proxy &

Get the token:

grep token ~/.kube/config | cut -f 2 -d ":" | sed "s/ //"

Visit http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

Istio Setup

export ISTIO_VERSION=1.5.4

follow the other steps as outlined to install the base system then install the tutorial as below

kubectl create namespace istiotutorial
kubectl label namespace istiotutorial istio-injection=enabled
istioctl manifest apply --set profile=demo
cd ~/istio-$ISTIO_VERSION
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml -n istiotutorial
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
echo http://$INGRESS_HOST:$INGRESS_PORT/productpage
istioctl dashboard kiali

More context at https://istio.io/docs/setup/getting-started/

do the above, final check : http://localhost:8001/api/v1/namespaces/istio-system/services/jaeger-query:16686/proxy/jaeger/search

Knative setup

Serving

kubectl apply -f https://github.com/knative/serving-operator/releases/download/v0.14.0/serving-operator.yaml

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

kubectl get deployment -n knative-serving

Eventing

kubectl apply -f https://github.com/knative/eventing-operator/releases/download/v0.14.1/eventing-operator.yaml

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

kubectl get deployment -n knative-eventing

More context: https://github.com/cloudacademy/knative-demo

Some services would fail to come up due to lack of CPU resources

update to the [imc-dispatcher] deploymnet:

 kubectl edit deployment imc-dispatcher -n knative-eventing
      resources:
        limits:
          cpu: 2200m
          memory: 2Gi
        requests:
          cpu: '10m'
          memory: 128Mi

See also knative/eventing#3036

The fix looks to be

KNATIVE_VERSION=0.14.2
kubectl apply -f https://github.com/knative/eventing/releases/download/v$KNATIVE_VERSION/in-memory-channel.yaml

Set up XIP.io --> NIP.io magic:

kubectl apply --filename https://github.com/knative/serving/releases/download/v0.13.0/serving-default-domain.yaml

See also: https://knative.dev/docs/install/installing-istio/#configuring-dns and 4. under https://knative.dev/v0.13-docs/install/any-kubernetes-cluster/#installing-the-serving-component

kubectl create namespace knative-monitoring

Dial down the requests.cpu to 100m via

kubectl edit ds node-exporter -n knative-monitoring

Accessing Graphana

https://github.com/knative/docs/blob/master/docs/serving/accessing-metrics.md eg. http://localhost:3000/d/im_gFbWik/knative-serving-revision-http-requests?orgId=1&refresh=5s

Knative Usage Tutorial

kubectl create namespace knativetutorial
kn service create greeter --namespace knativetutorial --image quay.io/rhdevelopers/knative-tutorial-greeter:quarkus
kn service list --namespace knativetutorial

Check the URL returned then:

kubectl get svc istio-ingressgateway --namespace istio-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}'
kn service update greeter --env "MESSAGE_PREFIX=Namaste" -n knativetutorial

Updating Service 'greeter' in namespace 'knativetutorial':

20.268s Traffic is not yet migrated to the latest revision. 20.392s Ingress has not yet been reconciled. 20.524s Ready to serve.

Check if the new revision is serving

 kn service describe greeter -n knativetutorial

if OK state is ?? instead of ++ with IngressNotConfigured just run the service update again

Check the URL again

Check pretty graphs: http://localhost:3000/d/im_gFbWik/knative-serving-revision-http-requests?orgId=1&refresh=5s&var-namespace=knativetutorial&var-configuration=greeter&var-revision=All

Tekton

kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml

install tkn https://github.com/tektoncd/cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment