Skip to content

Commit 446bfab

Browse files
Merge pull request #1411 from seanpang-vmware/topic/sp024667/easimp1
Add extension API server API implementation
2 parents 3499a03 + f479bc0 commit 446bfab

58 files changed

Lines changed: 9232 additions & 846 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ linters:
6060
- staticcheck
6161
# v1.EndpointSubset is deprecated in k8s v1.33+; same migration scope as above.
6262
text: "SA1019: v1.EndpointSubset is deprecated"
63+
- linters:
64+
- staticcheck
65+
# kubefake.NewSimpleClientset is deprecated in favour of NewClientset, which
66+
# requires generated apply configurations (--with-applyconfig). Until apply
67+
# configs are generated for this project the existing test helpers cannot be
68+
# migrated, so suppress the warning project-wide.
69+
text: "SA1019: kubefake.NewSimpleClientset is deprecated"
6370

6471
formatters:
6572
enable:

Makefile

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ changecrd: manifests generate generate-api-docs
4646
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
4747
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="github.com/vmware-tanzu/nsx-operator/pkg/apis/legacy/v1alpha1" output:crd:artifacts:config=build/yaml/crd/legacy/
4848
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="github.com/vmware-tanzu/nsx-operator/pkg/apis/vpc/v1alpha1" output:crd:artifacts:config=build/yaml/crd/vpc/
49-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="github.com/vmware-tanzu/nsx-operator/pkg/apis/eas/v1alpha1" output:crd:artifacts:config=build/yaml/crd/eas/
49+
# NOTE: EAS types are served by the generic API server (via APIService), NOT as CRDs.
50+
# Do NOT run controller-gen crd for pkg/apis/eas/v1alpha1 — installing EAS CRDs alongside
51+
# the APIService causes duplicate-resource conflicts in kube-apiserver.
5052

5153
.PHONY: generate
5254
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
@@ -97,6 +99,11 @@ build-clean: generate fmt vet ## Build clean binary.
9799
@mkdir -p $(BINDIR)
98100
GOOS=linux go build -o $(BINDIR)/clean $(GOFLAGS) -ldflags '$(LDFLAGS)' cmd_clean/main.go
99101

102+
.PHONY: build-eas
103+
build-eas: generate fmt vet ## Build EAS (Extension API Server) binary.
104+
@mkdir -p $(BINDIR)
105+
GOOS=linux go build -o $(BINDIR)/eas $(GOFLAGS) -ldflags '$(LDFLAGS)' cmd_eas/main.go
106+
100107
.PHONY: run
101108
run: manifests generate fmt vet ## Run a controller from your host.
102109
go run ./cmd/main.go
@@ -113,6 +120,10 @@ docker-push: ## Push docker image with the manager.
113120
photon:
114121
docker build -t github.com/vmware-tanzu/nsx-operator -f build/image/photon/Dockerfile .
115122

123+
.PHONY: eas
124+
eas:
125+
docker build -t github.com/vmware-tanzu/nsx-eas -f build/image/eas/Dockerfile .
126+
116127
.PHONY: clean
117128
clean:
118129
@rm -rf $(BINDIR)
@@ -164,6 +175,28 @@ code-generator: ## Download code-generator locally if necessary.
164175
generated: code-generator
165176
./hack/update-codegen.sh
166177

178+
OPENAPI_GEN = $(shell pwd)/bin/openapi-gen
179+
# openapi-gen moved from k8s.io/code-generator to k8s.io/kube-openapi (since ~v0.27).
180+
# We install it directly via "go install" in the project root so it uses the
181+
# version already pinned in go.mod without needing to create a throw-away module.
182+
.PHONY: openapi-gen
183+
openapi-gen: ## Build openapi-gen binary into bin/ (uses k8s.io/kube-openapi version from go.mod).
184+
@[ -f $(OPENAPI_GEN) ] || GOBIN=$(CURDIR)/bin go install k8s.io/kube-openapi/cmd/openapi-gen
185+
186+
.PHONY: generate-eas-openapi
187+
generate-eas-openapi: openapi-gen ## Generate OpenAPI definitions for EAS types plus the apimachinery meta/v1 and version types they reference.
188+
$(OPENAPI_GEN) \
189+
--output-dir pkg/apis/eas/v1alpha1 \
190+
--output-pkg github.com/vmware-tanzu/nsx-operator/pkg/apis/eas/v1alpha1 \
191+
--output-file zz_generated.openapi.go \
192+
--go-header-file hack/boilerplate.go.txt \
193+
--report-filename - \
194+
github.com/vmware-tanzu/nsx-operator/pkg/apis/eas/v1alpha1 \
195+
k8s.io/apimachinery/pkg/apis/meta/v1 \
196+
k8s.io/apimachinery/pkg/version
197+
@echo ""
198+
@echo "Generated pkg/apis/eas/v1alpha1/zz_generated.openapi.go"
199+
167200
CRD_REF_DOCS = $(shell pwd)/bin/crd-ref-docs
168201
.PHONY: crd-ref-docs
169202
crd-ref-docs: ## Install crd-ref-docs

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: 0 additions & 154 deletions
This file was deleted.

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

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

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

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

0 commit comments

Comments
 (0)