KNative
tip
KNative just has a service definition, no separate deployments and pods definitions are needed.
tip
Great with spot instances 👌
Invocation​
KNative can be invoked by:
- Function's http endpoint
- Event based (Kafka, SQS etc)
kn service invoke
- PingSource / Cron event
Definitions​
Cmd
kn service create helloworld \
--image gcr.io/your-project/helloworld \
--request cpu=100m,memory=128Mi \
--limit cpu=500m,memory=256Mi
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld
spec:
template:
spec:
containers:
- image: gcr.io/your-project/helloworld
args: ["-text=Hello from Knative!"]
ports:
- containerPort: 8080
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "256Mi"
KNative Global Resource Defaults
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
container-request-cpu: "200m"
container-request-memory: "256Mi"
PingSource​
kubectl apply -f ping-source.yaml
kubectl logs -l serving.knative.dev/service=helloworld --tail=100 --since=5m
kubectl describe pingsource ping-source
PingSource
apiVersion: sources.knative.dev/v1
kind: PingSource
metadata:
name: ping-source
spec:
schedule: "*/1 * * * *" # every minute
data: '{"message": "Hello from Ping!"}'
sink:
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: helloworld