Skip to content

Instantly share code, notes, and snippets.

@WilliamDenniss
Last active December 7, 2022 07:43
Show Gist options
  • Save WilliamDenniss/3cff8658411ee3342c3e35017c22898c to your computer and use it in GitHub Desktop.
Save WilliamDenniss/3cff8658411ee3342c3e35017c22898c to your computer and use it in GitHub Desktop.
Installation of Knative on a GKE Autopilot cluster
# Install Knative
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.0.0/serving-crds.yaml
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.0.0/serving-core.yaml
# Autopilot Mod: Remove annotation
kubectl patch -n knative-serving deployment activator --type=json -p='[{"op":"remove","path":"/spec/template/metadata/annotations/cluster-autoscaler.kubernetes.io~1safe-to-evict"}]'
kubectl patch -n knative-serving deployment autoscaler --type=json -p='[{"op":"remove","path":"/spec/template/metadata/annotations/cluster-autoscaler.kubernetes.io~1safe-to-evict"}]'
kubectl patch -n knative-serving deployment domainmapping-webhook --type=json -p='[{"op":"remove","path":"/spec/template/metadata/annotations/cluster-autoscaler.kubernetes.io~1safe-to-evict"}]'
kubectl patch -n knative-serving deployment webhook --type=json -p='[{"op":"remove","path":"/spec/template/metadata/annotations/cluster-autoscaler.kubernetes.io~1safe-to-evict"}]'
# Autopilot Mod: Provision Spare Capacity
kubectl create -f https://gist.githubusercontent.com/WilliamDenniss/3cff8658411ee3342c3e35017c22898c/raw/94aee82768a0dd3ff1f789bc8e5ae02f7ff2b408/knative-hello-world-balloon.yaml
# Install Kourier
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.0.0/kourier.yaml
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}'
# Configure DNS
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.0.0/serving-default-domain.yaml
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: balloon-priority
value: -10
preemptionPolicy: Never
globalDefault: false
description: "Balloon pod priority."
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: balloon
spec:
replicas: 1
selector:
matchLabels:
app: balloon-pod
template:
metadata:
labels:
app: balloon-pod
spec:
priorityClassName: balloon-priority
terminationGracePeriodSeconds: 0
containers:
- name: ubuntu
image: ubuntu
command: ["sleep"]
args: ["infinity"]
resources:
requests:
cpu: 725m
memory: 750Mi
@RileySeaburg
Copy link

You're a baller.
Thank you.

@ddelange
Copy link

ddelange commented Dec 7, 2022

apart from the safe-to-evict annotation that blocks cluster-autoscaler, there are also PDBs that prevent rolling redeploy even when the HPA is set to minScale 2. To allow a rolling redeploy:

kubectl -n knative-serving patch horizontalpodautoscaler activator -p '{"spec": {"minReplicas": 2}}'
kubectl -n knative-serving patch horizontalpodautoscaler webhook -p '{"spec": {"minReplicas": 2}}'
kubectl -n knative-serving patch poddisruptionbudget activator-pdb -p '{"spec": {"minAvailable": "50%"}}'
kubectl -n knative-serving patch poddisruptionbudget webhook-pdb -p '{"spec": {"minAvailable": "50%"}}'

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