polarismesh/polaris-controller
Fork: 36 Star: 64 (更新于 2024-12-01 13:36:41)
license: 暂无
Language: Go .
K8s Controller for K8s Service Sync and Polaris Sidecar Injection
最后发布版本: v1.7.2 ( 2024-07-09 16:17:58)
Polaris Controller
English | 中文
Introduce
polaris-controller For the docking of Polaris and K8s ecology, providing two optional functions:
- K8s Service Sync to Polaris: Sync K8s Service to Polaris, use Polaris for service discovery and governance
- polaris-sidecar Auto-inject: inject polaris-sidecar in app pod
The operating mode of sidecar in the Polaris-Controller provides two optional functions:
- LocalDNS (dns): Inject polaris-sidecar, realize service discovery and governance by intercepting DNS requests
- ServiceMesh (mesh): Inject polaris-sidecar and envoy, realize service discovery and governance through hijacking traffic, and develop low invasion
This document describes how to install and use polaris-controller in a K8s cluster.
Installation
Annotations
Annotations name | Annotations description |
---|---|
polarismesh.cn/sync | Whether to synchronize this service to Polarismesh.TRUE synchronization, False is not synchronized, default is not synchronized |
polarismesh.cn/aliasService | Synchronize K8S Service to PolarisMesh, and the name of the service alias created at the same time |
polarismesh.cn/aliasNamespace | The named space where the owner is located, with PolarisMesh.cn/aliasservice use |
Guidance
Full synchronization service
Start polaris-controller in full synchronization service mode, and synchronize all K8s services to Polaris. The startup configuration is as follows:
apiVersion: v1
kind: ConfigMap
data:
mesh: |-
serviceSync
mode: "all"
On-demand sync service
Start polaris-controller in the mode of on-demand synchronization service. By default, K8s Service will not be synchronized to Polaris. The startup configuration is as follows:
apiVersion: v1
kind: ConfigMap
data:
mesh: |-
serviceSync
mode: "demand"
If you need to synchronize all services in a Namespace to Polaris, please add Polaris annotation on the Namespace, the configuration is as follows:
apiVersion: v1
kind: Namespace
metadata:
name: default
annotations:
polarismesh.cn/sync: "true"
If you need to synchronize a Service to Polaris, please add the Polaris annotation on the Service, the configuration is as follows:
apiVersion: v1
kind: Service
metadata:
namespace: default
name: test
annotations:
polarismesh.cn/sync: "true"
If you need to synchronize a Service in a Namespace to Polaris and exclude a Service, the configuration is as follows:
apiVersion: v1
kind: Namespace
metadata:
name: default
annotations:
polarismesh.cn/sync: "true"
apiVersion: v1
kind: Service
metadata:
namespace: default
name: test
annotations:
polarismesh.cn/sync: "false"
Create service alias
Polaris supports the function of service alias, allowing one or more service aliases to be set for a service. The effect of using service alias for service discovery is the same as that of using service name for service discovery.
The name mapping rules for polaris-controller to synchronize K8s Service to Polaris are as follows:
- K8s Namespace as Polaris namespace name
- K8s Service as the service name of Polaris
If you need to create a service alias for Service when it is synchronized to Polaris, the configuration is as follows:
apiVersion: v1
kind: Service
metadata:
namespace: default
name: test
annotations:
polarismesh.cn/aliasNamespace: aliasDefault
polarismesh.cn/aliasService: aliasTest
Sidecar auto inject
If polaris-sidecar needs to be used, it can be automatically injected in the application Pod, and the configuration is as follows:
kubectl label namespace default polaris-injection=enabled
Check whether K8s Namespace supports automatic injection of polaris-sidecar:
kubectl get namespace -L polaris-injection
NAME STATUS AGE POLARIS-INJECTION
default Active 3d2h enabled
View the operation mode after polaris-sidecar injection corresponding to K8s Namespace:
kubectl get namespace -L polaris-sidecar-mode
NAME STATUS AGE POLARIS-SIDECAR-MODE
default Active 10d mesh
After automatic injection is enabled, newly created Pods will be automatically injected, and existing Pods will not be automatically injected into polaris-sidecar. If you want stock pods to experience polaris-sidecar as well, for pods managed by Deployment, DaemonSet or StatefulSet controllers, you can run the following command
# Deployment
kubectl rollout restart deployment/DEPLOYMENT_NAME --namespace NAMESPACE
# DaemonSet
kubectl rollout restart daemonset/DAEMONSET_NAME --namespace NAMESPACE
# StatefulSet
kubectl rollout restart statefulset/STATEFULSET_NAME --namespace NAMESPACE
最近版本更新:(数据更新于 2024-09-10 08:20:50)
2024-07-09 16:17:58 v1.7.2
2024-06-26 21:21:41 v1.7.1
2024-03-19 11:17:11 v1.7.1
2024-02-04 00:51:49 v1.7.0
2024-01-23 16:48:43 v1.7.0-alpha.3
2024-01-07 20:15:54 v1.7.0-beta
2024-01-06 23:23:45 v1.7.0-alpha.2
2024-01-05 16:09:35 v1.7.0-alpha.1
2024-01-04 15:47:31 v1.7.0-alpha
2023-12-26 21:10:52 v1.7.0-beta
主题(topics):
kubernetes, polarismesh
polarismesh/polaris-controller同语言 Go最近更新仓库
2024-12-22 07:52:58 navidrome/navidrome
2024-12-21 20:15:12 SagerNet/sing-box
2024-12-21 03:25:54 SpecterOps/BloodHound
2024-12-19 23:11:24 shadow1ng/fscan
2024-12-19 21:50:56 minio/minio
2024-12-19 10:04:39 istio/istio