Skip to main content
Version: 2.6.0

Build And Deploy Kubernetes Controller

This article introduces how to use ShenYu Ingress Controller.

Construct#

It is recommended to refer to Custom Deployment to build a custom gateway, add the shenyu-kubernetes-controller dependency to the Maven dependency of the gateway, and the gateway can integrate the kubernetes controller.

         <dependency>             <groupId>org.apache.shenyu</groupId>             <artifactId>shenyu-spring-boot-starter-k8s</artifactId>             <version>${project.version}</version>         </dependency>

You can also directly use the officially built docker image (TODO, unfinished)

deployment#

K8s deployment files can refer to:

apiVersion: v1kind: Namespacemetadata:  name: shenyu-ingress---apiVersion: v1automountServiceAccountToken: truekind: ServiceAccountmetadata:  name: shenyu-ingress-controller  namespace: shenyu-ingress---apiVersion: apps/v1kind: Deploymentmetadata:  name: shenyu-ingress-controller  namespace: shenyu-ingress  labels:    app: shenyu-ingress-controller    all: shenyu-ingress-controllerspec:  replicas: 1  selector:    matchLabels:      app: shenyu-ingress-controller  template:    metadata:      labels:        app: shenyu-ingress-controller    spec:      containers:      - name: shenyu-ingress-controller        image: apache/shenyu-integrated-test-k8s-ingress:latest        ports:        - containerPort: 9195        imagePullPolicy: IfNotPresent      serviceAccountName: shenyu-ingress-controller---apiVersion: v1kind: Servicemetadata:  name: shenyu-ingress-controller  namespace: shenyu-ingressspec:  selector:    app: shenyu-ingress-controller  type: NodePort  ports:    - port: 9195      targetPort: 9195      nodePort: 30095---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRolemetadata:  name: shenyu-ingress-controllerrules:- apiGroups:  - ""  resources:  - namespaces  - services  - endpoints  - secrets  - pods  verbs:  - get  - list  - watch- apiGroups:  - networking.k8s.io  resources:  - ingresses  verbs:  - get  - list  - watch---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:  name: shenyu-ingress-controller  namespace: shenyu-ingressroleRef:  apiGroup: rbac.authorization.k8s.io  kind: ClusterRole  name: shenyu-ingress-controllersubjects:- kind: ServiceAccount  name: shenyu-ingress-controller  namespace: shenyu-ingress

Among them, Service can be changed to LoadBalancer type according to the actual situation.