TkeServiceConfig is a custom resource definition (CRD) provided by TKE to help you manage the various configurations of CLB with an Ingress more flexibly.Ingress YAML can be configured through TkeServiceConfig.TkeServiceConfig helps you quickly configure CLB. You can specify a target configuration for application to an Ingress through the Ingress annotation ingress.cloud.tencent.com/tke-service-config:<config-name>.TkeServiceConfig resource needs to be in the same namespace as the Ingress.TkeServiceConfig doesn't help you configure and modify the protocol, port, domain name, and forwarding path; instead, you need to describe them in the configuration to specify the forwarding rule for delivery by the configuration.TkeServiceConfig. Currently, configurations are mainly provided for CLB health check and backend access.spec.loadBalancer.l7Listeners.protocol: layer-7 protocolspec.loadBalancer.l7Listeners.port: listening portspec.loadBalancer.l7Listeners.protocol: layer-7 protocolspec.loadBalancer.l7Listeners.port: listening portspec.loadBalancer.l7Listeners.domains[].domain: domain namespec.loadBalancer.l7Listeners.domains[].rules[].url: forwarding pathspec.loadBalancer.l7listeners.protocol.domain.rules.url.forwardType: specified backend protocol, currently supports HTTP/HTTPS/GRPC.domain field.ingress.cloud.tencent.com/tke-service-config-auto: "true" when creating an Ingress, <IngressName>-auto-ingress-config will be created automatically. You can also specify the TkeServiceConfig you created on your own directly through ingress.cloud.tencent.com/tke-service-config:<config-name> . The two annotations cannot be used at the same time. -auto-service-config or -auto-ingress-config.TkeServiceConfig has the following sync behaviors:Ingress-Controller will automatically add the corresponding TkeServiceConfig configuration segment for the rule if it doesn't exist.Ingress-Controller component will automatically delete the corresponding TkeServiceConfig segment.TkeServiceConfig will also be deleted.TkeServiceConfig of the Ingress, the TkeServiceConfig content will also be applied to CLB.TkeServiceConfig configuration reference, which is imported by the Service through the ingress.cloud.tencent.com/tke-service-config:<config-name> annotation.TkeServiceConfig has the following sync behaviors:TkeServiceConfig configuration, CLB of the Ingress that imports the configuration will set sync based on the new TkeServiceConfig.apiVersion: apps/v1kind: Deploymentmetadata:labels:app: jettyname: jetty-deploymentnamespace: defaultspec:progressDeadlineSeconds: 600replicas: 3revisionHistoryLimit: 10selector:matchLabels:app: jettystrategy:rollingUpdate:maxSurge: 25%maxUnavailable: 25%type: RollingUpdatetemplate:metadata:creationTimestamp: nulllabels:app: jettyspec:containers:- image: jetty:9.4.27-jre11imagePullPolicy: IfNotPresentname: jettyports:- containerPort: 80protocol: TCP- containerPort: 443protocol: TCPresources: {}terminationMessagePath: /dev/termination-logterminationMessagePolicy: FilednsPolicy: ClusterFirstrestartPolicy: AlwaysschedulerName: default-schedulersecurityContext: {}terminationGracePeriodSeconds: 30
apiVersion: v1kind: Servicemetadata:name: jetty-servicenamespace: defaultspec:ports:- name: tcp-80-80port: 80protocol: TCPtargetPort: 80- name: tcp-443-443port: 443protocol: TCPtargetPort: 443selector:app: jettytype: NodePort
NodePort type, with two TCP services declared, one on port 80 and the other on port 443.apiVersion: extensions/v1beta1apiVersion: networking.k8s.io/v1kind: Ingressmetadata:annotations:kubernetes.io/ingress.rule-mix: "true"kubernetes.io/ingress.http-rules: '[{"path":"/health","backend":{"serviceName":"jetty-service","servicePort":"80"}}]'kubernetes.io/ingress.https-rules: '[{"path":"/","backend":{"serviceName":"jetty-service","servicePort":"443","host":"sample.tencent.com"}}]'ingress.cloud.tencent.com/tke-service-config: jetty-ingress-config# Specify the existing `tke-service-config`# ingress.cloud.tencent.com/tke-service-config-auto: "true"# Automatically create a `tke-service-config`name: jetty-ingressnamespace: defaultspec:rules:- http:paths:- backend:serviceName: jetty-serviceservicePort: 80path: /health- host: "sample.tencent.com"http:paths:- backend:serviceName: jetty-serviceservicePort: 443path: /- http:paths:- backend:service:name: jetty-serviceport:number: 80path: /healthpathType: ImplementationSpecific- host: "sample.tencent.com"http:paths:- backend:service:name: jetty-serviceport:number: 80path: /pathType: ImplementationSpecifictls:- secretName: jetty-cert-secret- secretName: jetty-cert-secret
sample.tencent.com domain name is used to expose an HTTPS service./health, and that of the HTTPS service is /.jetty-ingress-config CLB configuration is used.TkeServiceConfig: jetty-ingress-config.yamlapiVersion: cloud.tencent.com/v1alpha1kind: TkeServiceConfigmetadata:name: jetty-ingress-confignamespace: defaultspec:loadBalancer:l7Listeners:- protocol: HTTPport: 80domains:- domain: "" # When `domain` is null, the VIP is used as the domain namerules:- url: "/health"forwardType: HTTP # It specifies HTTP as the backend protocol, currently supports HTTP/HTTPS/GRPChealthCheck:enable: false- protocol: HTTPSport: 443defaultServer: "sample.tencent.com" # Default domain namekeepaliveEnable: 1 # Enable persistent connection for the listenerdomains:- domain: "sample.tencent.com"rules:- url: "/"forwardType: HTTPS # It specifies HTTPS as the backend protocol, currently supports HTTP/HTTPS/GRPCsession:enable: truesessionExpireTime: 3600healthCheck:enable: trueintervalTime: 10 # `intervalTime` must be greater than `timeout`; otherwise, an error will occur.timeout: 5 # `timeout` must be smaller than `intervalTime`; otherwise, an error will occur.healthNum: 2unHealthNum: 2httpCheckPath: "/checkHealth"httpCheckDomain: "sample.tencent.com" # Note: the health check must use a fixed domain name for detection. If you enter a wildcard domain name in `.spec.loadBalancer.l7Listeners.protocol.domains.domain`, be sure to use the `httpCheckDomain` field to specify the domain name that requires health check; otherwise, the wildcard domain name does not support health check.httpCheckMethod: HEADhttpCode: 31 # Optional value: 1~31, default is 31. 1 means the return value 1xx after detection represents health, 2 means 2xx represents health, 4 means 3xx represents health, 8 means 4xx represents health, and 16 means 5xx represents health. If you want multiple return codes to represent health, add the corresponding values.sourceIpType: 0 # Optional value: 0 or 1, set the health check source IP. 0 represents the load balancing VIP, and 1 represents the 100.64.0.0/10 network segment IP. For domain-based clbs, the default value is 1 and can only be 1. For non-domain-based clbs, the default value is not necessarily. You can check whether you can see the VIP detection method on the clb console configuration page. If you can see it, the default value is 0, otherwise it is 1. For more details, see https://www.tencentcloud.com/document/product/214/53639.checkType: "HTTPS" # Optional value:HTTP, HTTPS or TCP,default is HTTP。After 2024.06, the new cluster support field is changed, and the inventory cluster can be supported by the backend component of work order upgrade if necessary. When forwardType is HTTPS, checkType can only be TCP or HTTPS.scheduler: WRR # Optional value: WRR、LEAST_CONN、IP_HASH
TkeServiceConfig is jetty-ingress-config, and in the layer-7 listener configuration, two configuration segments are declared:/health path is disabled.sample.tencent.com. Under this domain name, only a forwarding rule configuration with the forwarding path of / is described, which contains the following:HEAD requests, the check path is /checkHealth, and the check domain name is sample.tencent.com.$ kubectl apply -f jetty-deployment.yaml$ kubectl apply -f jetty-service.yaml$ kubectl apply -f jetty-ingress.yaml$ kubectl apply -f jetty-ingress-config.yaml$ kubectl get podsNAME READY STATUS RESTARTS AGEjetty-deployment-8694c44b4c-cxscn 1/1 Running 0 8m8sjetty-deployment-8694c44b4c-mk285 1/1 Running 0 8m8sjetty-deployment-8694c44b4c-rjrtm 1/1 Running 0 8m8s# Get the `TkeServiceConfig` configuration list$ kubectl get tkeserviceconfigs.cloud.tencent.comNAME AGEjetty-ingress-config 52s# Update and modify the `TkeServiceConfig` configuration$ kubectl edit tkeserviceconfigs.cloud.tencent.com jetty-ingress-configtkeserviceconfigs.cloud.tencent.com/jetty-ingress-config edited
Feedback