本文基于knative v0.10
1 gc
控制revision的数量。
knative controller关联了一个configmap:knative-serving/config-gc,它包含了gc控制器的参数,用于控制revision数量。
2 serverlessservice
处理serverlessservices.networking.internal.knative.dev资源(简写sks)。
[root@k8s-1 ~]# kubectl get sks helloworld-go-external-sfp8c -oyaml
apiVersion: networking.internal.knative.dev/v1alpha1
kind: ServerlessService
metadata:
annotations:
autoscaling.knative.dev/class: kpa.autoscaling.knative.dev
serving.knative.dev/creator: kubernetes-admin
creationTimestamp: "2019-12-05T07:11:48Z"
generation: 2
labels:
app: helloworld-go-external-sfp8c
serving.knative.dev/configuration: helloworld-go-external
serving.knative.dev/configurationGeneration: "1"
serving.knative.dev/revision: helloworld-go-external-sfp8c
serving.knative.dev/revisionUID: eaa0e7aa-3c44-45d9-8c97-467a51716793
serving.knative.dev/service: helloworld-go-external
name: helloworld-go-external-sfp8c
namespace: default
ownerReferences:
- apiVersion: autoscaling.internal.knative.dev/v1alpha1
blockOwnerDeletion: true
controller: true
kind: PodAutoscaler
name: helloworld-go-external-sfp8c
uid: 2ab93862-b921-4c59-872c-508aedc9bf19
resourceVersion: "141981"
selfLink: /apis/networking.internal.knative.dev/v1alpha1/namespaces/default/serverlessservices/helloworld-go-external-sfp8c
uid: 4640a2c6-9699-4bea-819a-26baaf416d88
spec:
ProtocolType: http1
mode: Proxy
objectRef:
apiVersion: apps/v1
kind: Deployment
name: helloworld-go-external-sfp8c-deployment
status:
conditions:
- lastTransitionTime: "2019-12-05T07:26:32Z"
message: Revision is backed by Activator
reason: ActivatorEndpointsPopulated
severity: Info
status: "True"
type: ActivatorEndpointsPopulated
- lastTransitionTime: "2019-12-09T09:54:10Z"
message: K8s Service is not ready
reason: NoHealthyBackends
status: Unknown
type: EndpointsPopulated
- lastTransitionTime: "2019-12-09T09:54:10Z"
message: K8s Service is not ready
reason: NoHealthyBackends
status: Unknown
type: Ready
observedGeneration: 2
privateServiceName: helloworld-go-external-sfp8c-private
serviceName: helloworld-go-external-sfp8c
2.1 创建一个同名service
[root@k8s-1 ~]# kubectl get svc -oyaml helloworld-go-external-sfp8c
apiVersion: v1
kind: Service
metadata:
annotations:
autoscaling.knative.dev/class: kpa.autoscaling.knative.dev
serving.knative.dev/creator: kubernetes-admin
creationTimestamp: "2019-12-05T07:11:48Z"
labels:
app: helloworld-go-external-sfp8c
networking.internal.knative.dev/serverlessservice: helloworld-go-external-sfp8c
networking.internal.knative.dev/serviceType: Public
serving.knative.dev/configuration: helloworld-go-external
serving.knative.dev/configurationGeneration: "1"
serving.knative.dev/revision: helloworld-go-external-sfp8c
serving.knative.dev/revisionUID: eaa0e7aa-3c44-45d9-8c97-467a51716793
serving.knative.dev/service: helloworld-go-external
name: helloworld-go-external-sfp8c
namespace: default
ownerReferences:
- apiVersion: networking.internal.knative.dev/v1alpha1
blockOwnerDeletion: true
controller: true
kind: ServerlessService
name: helloworld-go-external-sfp8c
uid: 4640a2c6-9699-4bea-819a-26baaf416d88
resourceVersion: "111055"
selfLink: /api/v1/namespaces/default/services/helloworld-go-external-sfp8c
uid: 13f1a086-8e76-48c6-b131-d0547f8a5b7c
spec:
clusterIP: 10.96.36.111
ports:
- name: http
port: 80
protocol: TCP
targetPort: 8012
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
注意到该svc没有selector
。同时创建一个ep。
[root@k8s-1 ~]# kubectl get ep helloworld-go-external-sfp8c -oyaml
apiVersion: v1
kind: Endpoints
metadata:
annotations:
autoscaling.knative.dev/class: kpa.autoscaling.knative.dev