Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
# endpoints-operator
> 场景对于外部场景使用固定的endpoint维护增加探活功能

根据service数据生成endpoint数据

1. 根据service的port映射对应的endpoints数据
2. targetPort 不能使用string只能对应int数据
## 背景
在很多场景下,用户集群可能需要访问集群外的数据,这时候又想使用service提供的功能,我们一般创建一个空的service,并手动绑定对应的endpoint.

```yaml
apiVersion: v1
kind: Service
metadata:
name: mysql-kube
namespace: default
spec:
clusterIP: 10.96.0.100
clusterIPs:
- 10.96.0.100
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: mysql
port: 3306
protocol: TCP
targetPort: 3306
sessionAffinity: None
type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
name: mysql-kube
namespace: default
subsets:
- addresses:
- ip: 10.0.99.251
ports:
- name: mysql
port: 3306
protocol: TCP
```

这样手动设置了对应的

## Usage

Expand Down
8 changes: 1 addition & 7 deletions config/demo/dmz-kube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,11 @@ spec:
timeoutSeconds: 1
hosts:
- 10.0.112.255
- 10.0.112.251
ports:
- name: https
port: 6443
protocol: TCP
targetPort: 6443
tcpSocket:
enable: true
- name: http
port: 80
protocol: TCP
targetPort: 80
httpGet:
path: /
scheme: http
2 changes: 1 addition & 1 deletion controllers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (c *Reconciler) updateCondition(cep *v1beta1.ClusterEndpoint, condition v1b
for i, cond := range cep.Status.Conditions {
if cond.Type == condition.Type {
hasCondition = true
if cond.Reason != condition.Reason || cond.Status != condition.Status {
if cond.Reason != condition.Reason || cond.Status != condition.Status || cond.Message != condition.Message {
cep.Status.Conditions[i] = condition
}
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (c *Reconciler) syncEndpoint(ctx context.Context, cep *v1beta1.ClusterEndpo
})
}
subErr := ToAggregate(errors)
if len(subErr.Errors()) != 0 {
if subErr != nil && len(subErr.Errors()) != 0 {
e = append(e, fmt.Errorf(subErr.Error()))
}

Expand Down