Skip to content

Commit 59a983e

Browse files
Add EAS api implementation
1. add a new eas service in nsx-operator 2. register eas service to k8s api server 3. start a http service on 9553 port 4. add eas service implentations for ip usages api yamls
1 parent 73f6e84 commit 59a983e

39 files changed

Lines changed: 5029 additions & 267 deletions

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ build-clean: generate fmt vet ## Build clean binary.
9797
@mkdir -p $(BINDIR)
9898
GOOS=linux go build -o $(BINDIR)/clean $(GOFLAGS) -ldflags '$(LDFLAGS)' cmd_clean/main.go
9999

100+
.PHONY: build-eas
101+
build-eas: generate fmt vet ## Build EAS (Extension API Server) binary.
102+
@mkdir -p $(BINDIR)
103+
GOOS=linux go build -o $(BINDIR)/eas $(GOFLAGS) -ldflags '$(LDFLAGS)' cmd_eas/main.go
104+
100105
.PHONY: run
101106
run: manifests generate fmt vet ## Run a controller from your host.
102107
go run ./cmd/main.go
@@ -113,6 +118,10 @@ docker-push: ## Push docker image with the manager.
113118
photon:
114119
docker build -t github.com/vmware-tanzu/nsx-operator -f build/image/photon/Dockerfile .
115120

121+
.PHONY: eas
122+
eas:
123+
docker build -t github.com/vmware-tanzu/nsx-eas -f build/image/eas/Dockerfile .
124+
116125
.PHONY: clean
117126
clean:
118127
@rm -rf $(BINDIR)

build/image/eas/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM golang:1.25.7 as golang-build
2+
3+
WORKDIR /source
4+
5+
COPY . /source
6+
RUN CGO_ENABLED=0 go build -o eas cmd_eas/main.go
7+
8+
FROM photon
9+
10+
RUN tdnf -y install shadow && \
11+
useradd -s /bin/bash eas
12+
13+
COPY --from=golang-build /source/eas /usr/local/bin/
14+
15+
USER eas
16+
17+
ENTRYPOINT ["/usr/local/bin/eas"]

build/yaml/crd/eas/eas.nsx.vmware.com_ipblockusages.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# DO NOT INSTALL - Schema reference only.
2+
# These CRD definitions are for documentation and schema validation purposes only.
3+
# The eas.nsx.vmware.com/v1alpha1 group is served by the EAS Extension API Server
4+
# (not from etcd). Installing these CRDs causes kube-aggregator to create an
5+
# auto-managed APIService with no spec.service, which routes all requests to etcd
6+
# (returning empty results) instead of the EAS backend.
7+
# See build/yaml/eas/apiservice.yaml for the correct APIService configuration.
18
---
29
apiVersion: apiextensions.k8s.io/v1
310
kind: CustomResourceDefinition

build/yaml/crd/eas/eas.nsx.vmware.com_subnetdhcpserverstats.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# DO NOT INSTALL - Schema reference only.
2+
# These CRD definitions are for documentation and schema validation purposes only.
3+
# The eas.nsx.vmware.com/v1alpha1 group is served by the EAS Extension API Server
4+
# (not from etcd). Installing these CRDs causes kube-aggregator to create an
5+
# auto-managed APIService with no spec.service, which routes all requests to etcd
6+
# (returning empty results) instead of the EAS backend.
7+
# See build/yaml/eas/apiservice.yaml for the correct APIService configuration.
18
---
29
apiVersion: apiextensions.k8s.io/v1
310
kind: CustomResourceDefinition

build/yaml/crd/eas/eas.nsx.vmware.com_subnetippools.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# DO NOT INSTALL - Schema reference only.
2+
# These CRD definitions are for documentation and schema validation purposes only.
3+
# The eas.nsx.vmware.com/v1alpha1 group is served by the EAS Extension API Server
4+
# (not from etcd). Installing these CRDs causes kube-aggregator to create an
5+
# auto-managed APIService with no spec.service, which routes all requests to etcd
6+
# (returning empty results) instead of the EAS backend.
7+
# See build/yaml/eas/apiservice.yaml for the correct APIService configuration.
18
---
29
apiVersion: apiextensions.k8s.io/v1
310
kind: CustomResourceDefinition

build/yaml/crd/eas/eas.nsx.vmware.com_vpcipaddressusages.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# DO NOT INSTALL - Schema reference only.
2+
# These CRD definitions are for documentation and schema validation purposes only.
3+
# The eas.nsx.vmware.com/v1alpha1 group is served by the EAS Extension API Server
4+
# (not from etcd). Installing these CRDs causes kube-aggregator to create an
5+
# auto-managed APIService with no spec.service, which routes all requests to etcd
6+
# (returning empty results) instead of the EAS backend.
7+
# See build/yaml/eas/apiservice.yaml for the correct APIService configuration.
18
---
29
apiVersion: apiextensions.k8s.io/v1
310
kind: CustomResourceDefinition
@@ -107,7 +114,8 @@ spec:
107114
- start
108115
type: object
109116
type: array
110-
name:
117+
ipBlockID:
118+
description: NSX resource ID of the IP block (leaf segment of the policy path).
111119
type: string
112120
percentageUsed:
113121
description: Percentage of used IP address space.

build/yaml/eas/apiservice.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ spec:
1010
service:
1111
name: nsx-eas
1212
namespace: vmware-system-nsx
13-
insecureSkipTLSVerify: true
13+
insecureSkipTLSVerify: true

build/yaml/eas/clusterrole.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ rules:
1010
- subnetippools
1111
- subnetdhcpserverstats
1212
verbs: ["get", "list"]
13+
- apiGroups: ["apiregistration.k8s.io"]
14+
resources: ["apiservices"]
15+
verbs: ["get", "create", "update", "patch"]
1316
---
1417
apiVersion: rbac.authorization.k8s.io/v1
1518
kind: ClusterRoleBinding

build/yaml/eas/eas-service.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: nsx-eas
5+
namespace: vmware-system-nsx
6+
labels:
7+
app.kubernetes.io/name: service
8+
app.kubernetes.io/instance: eas-service
9+
app.kubernetes.io/component: eas
10+
app.kubernetes.io/created-by: nsx-operator
11+
app.kubernetes.io/part-of: nsx-operator
12+
app.kubernetes.io/managed-by: kustomize
13+
spec:
14+
ports:
15+
- port: 443
16+
targetPort: 9553
17+
protocol: TCP
18+
selector:
19+
component: nsx-ncp

build/yaml/eas/service.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)