Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
3a3f643
docs: add Gateway API GEP-713 design spec
anngdinh May 8, 2026
be130a6
docs: drop AWS-LBC-style Gateway API spec and plan
anngdinh May 8, 2026
ebbf188
docs: add Gateway API GEP-713 Phase 1 implementation plan
anngdinh May 8, 2026
c25e8d5
build(gateway): add sigs.k8s.io/gateway-api v1.2.0 dependency
anngdinh May 8, 2026
f736b7d
feat(gateway/api): scaffold gateway.vks.vngcloud.vn/v1alpha1 group
anngdinh May 8, 2026
3768aeb
feat(gateway): add domain finalizers and GatewayClass controller names
anngdinh May 8, 2026
7a6a032
feat(gateway/api): add shared policy status + target-ref re-exports
anngdinh May 8, 2026
407b6ee
feat(gateway/api): add VKSGatewayPolicy types
anngdinh May 8, 2026
6719982
feat(gateway/api): add VKSBackendPolicy types
anngdinh May 8, 2026
a2ba669
feat(gateway/api): add VKSHealthCheckPolicy types
anngdinh May 8, 2026
b58c861
feat(gateway/api): add VKSRoutePolicy types
anngdinh May 8, 2026
91bf9d6
fix(gateway/api): mark re-exported aliases as no-deepcopy
anngdinh May 8, 2026
ed94ff8
build(gateway/api): embed and sync gateway CRDs
anngdinh May 8, 2026
6b012ec
feat(gateway/api): generate deepcopy and CRD manifests for VKS policies
anngdinh May 8, 2026
e009a0d
feat(gateway/pkg): add hostname matching helpers
anngdinh May 8, 2026
5314fe0
feat(gateway/pkg): add synthetic-pool naming and weight scaling
anngdinh May 8, 2026
47170fb
feat(gateway/pkg): add policy target-ref matching helpers
anngdinh May 8, 2026
fbcbfb9
feat(gateway/shared): add protocol classifier
anngdinh May 8, 2026
c645785
feat(gateway/shared): add condition + ancestor-status helpers
anngdinh May 8, 2026
485c84e
feat(gateway/shared): add match-specificity ordering
anngdinh May 8, 2026
cb2e4f4
feat(gateway/shared): add reverse indexes for routes + 4 policy CRDs
anngdinh May 8, 2026
0913b8a
feat(gateway/shared): add finalizer helpers
anngdinh May 8, 2026
b48e273
feat(gateway/shared): add cross-resource event handlers
anngdinh May 8, 2026
9348e57
feat(gateway/uc): add ReferenceGrant evaluator
anngdinh May 8, 2026
d8eee77
feat(gateway/uc): add Direct-policy resolver (oldest-wins)
anngdinh May 8, 2026
a320c27
feat(gateway/api): implement Matches() adapter on all 4 policy CRDs
anngdinh May 8, 2026
e0402ad
fix(gateway/api): trim VKSPolicy schemas to vngcloud LB-supported fea…
anngdinh May 8, 2026
46a7517
feat(gateway/alb): wire ALB Gateway use case + reconciler (Phase 1A s…
anngdinh May 8, 2026
a5b5f4b
feat(gateway/alb): translate Gateway listeners to LBC.Listeners (Phas…
anngdinh May 8, 2026
e97bb80
feat(gateway/alb): TLS cert handling on HTTPS listeners (Phase D)
anngdinh May 8, 2026
2a7e663
feat(gateway/alb): HTTPRoute → Pools + L7 Policies (Phase E initial)
anngdinh May 8, 2026
497c6f7
feat(gateway/alb): VKSBackendPolicy + HealthCheckPolicy + RoutePolicy…
anngdinh May 8, 2026
1128889
feat(gateway/alb): mirror LBC.Status to Gateway.Status (Phase F)
anngdinh May 8, 2026
8e48933
feat(gateway/alb): GatewayClass acceptance + register field indexes (…
anngdinh May 8, 2026
ec04eec
fix(gateway/alb): make Init return error when defaults aren't populated
anngdinh May 8, 2026
756ff34
fix(gateway/alb): prefix LBC listener name to satisfy cloud's 5-char …
anngdinh May 8, 2026
526dd45
style(gateway/alb): apply gofmt + goimports cleanup
anngdinh May 8, 2026
88cef20
build(gateway/alb): enable ALB Gateway controller in 'make run'
anngdinh May 8, 2026
dccb7c3
feat(gateway/alb): VKSBackendPolicy.TargetType (instance|ip) + node-I…
anngdinh May 8, 2026
3935baf
test(gateway): add unit + envtest coverage for the entire Phase 1 sur…
anngdinh May 8, 2026
75e9b90
refactor(gateway/alb): prefix all cloud-side resource names with vks_
anngdinh May 8, 2026
8d63aef
fix(gateway/alb): handle filter-only HTTPRoute rules + HTTP healthche…
anngdinh May 8, 2026
c4c8572
test(gateway/alb): add kitchen-sink end-to-end fixture
anngdinh May 8, 2026
4eac058
test(gateway/alb): trim kitchen-sink fixture to fit POLICY_PER_LB=10 …
anngdinh May 8, 2026
dd8f247
fix(gateway/alb): watch VKSBackend/HealthCheck/RoutePolicy for reconcile
anngdinh May 8, 2026
04bb2d6
refactor(gateway/alb): generate cloud names via utils.NameHelper
anngdinh May 9, 2026
b0f6421
fix(lbc): treat nil and empty insertHeaders as equal in listener diff
anngdinh May 8, 2026
1c1d282
refactor(gateway/alb): restore custom names for listener/policy
anngdinh May 9, 2026
3faa016
feat(gateway/alb): order policies by match specificity (Gateway-API s…
anngdinh May 9, 2026
4980417
test(gateway/alb): add envtest specs for live-cluster smoke parity
anngdinh May 9, 2026
9af9a97
fix(gateway/alb): close defaults gaps vs ingress/service
anngdinh May 9, 2026
6d54756
fix(gateway/alb): make init a manager Runnable, drop 10s sleep penalty
anngdinh May 9, 2026
b41284b
feat(gateway/alb): fall back to node-label clusterID, matching ingres…
anngdinh May 9, 2026
22e0a95
test(gateway/alb): unit-test albClassPredicate and conditionsEqualIgn…
anngdinh May 9, 2026
8ba4b6f
fix(lbc/policy): delete orphans by name before creating new ones
anngdinh May 9, 2026
40e3009
fix(gateway): break policy-position ties deterministically
anngdinh May 9, 2026
0c88ad6
feat(gateway/alb): expose health-check port, method, version on VKSHe…
anngdinh Jun 10, 2026
f1f955a
feat(gateway/alb): custom LB name, prefer-zone, and BYO-LB adoption
anngdinh Jun 10, 2026
c53e457
test(gateway/alb): add opt-in real-cluster e2e suite for the ALB Gate…
anngdinh Jun 10, 2026
d30f343
feat(gateway/alb): write HTTPRoute parent status (Accepted/ResolvedRefs)
anngdinh Jun 10, 2026
f1bf91c
feat(gateway/policies): add Direct-policy validator controllers (status)
anngdinh Jun 10, 2026
1f874cb
docs(gateway): mark HTTPRoute + policy status as implemented in Phase 1
anngdinh Jun 10, 2026
96825a8
feat(gateway/alb): cross-ns ReferenceGrant, backend-config-mismatch, …
anngdinh Jun 11, 2026
053992b
feat(gateway/alb): ship GatewayClass via Helm + enable ALB gateway by…
anngdinh Jun 11, 2026
8630eaf
test(gateway/alb): e2e specs for cross-ns ReferenceGrant, selector, m…
anngdinh Jun 11, 2026
fc85528
test(e2e): close remaining gateway e2e gaps; fix kitchen fixture vs B…
anngdinh Jun 11, 2026
f9b2189
docs: user-facing Gateway API (ALB) guide
anngdinh Jun 11, 2026
ec0d95d
feat(gateway/nlb): Phase 2 — NLB (L4) Gateway API support (TCP/UDP)
anngdinh Jun 11, 2026
ff5e08f
test(e2e): fix NLB assertions to the real LBC Type value (Layer 4)
anngdinh Jun 11, 2026
9c79e50
test(gateway/nlb): broaden NLB coverage (unit + envtest)
anngdinh Jun 11, 2026
ca7c808
test(gateway/nlb): port Service/Ingress envtest scenarios to the NLB …
anngdinh Jun 12, 2026
cf9275b
chore: enable NLB in make run; fix pkg/utils test gomega fail-handler
anngdinh Jun 12, 2026
ddecb22
feat(gateway/nlb): VKSBackendPolicy.proxyProtocol -> PROXY pool protocol
anngdinh Jun 12, 2026
4479500
docs(gateway/nlb): real client IP via NLB + HAProxy + PROXY protocol
anngdinh Jun 12, 2026
062dc97
docs: promote NLB+HAProxy real-client-IP use case to a user guide
anngdinh Jun 12, 2026
c778188
feat(gateway): InterVPC scheme via privateZoneId
anngdinh Jun 12, 2026
9048fe0
test(gateway): cover target-node-labels -> node-selector wiring
anngdinh Jun 13, 2026
ece97a3
docs(gateway): policy scope model + multi-Gateway (external/internal)…
anngdinh Jun 13, 2026
615d983
Merge branch 'main' into gateway-api-gep713-phase1 (add docs-preview …
anngdinh Jun 15, 2026
357d54b
[build] feat(gateway): disable Gateway-API by default
anngdinh Jun 16, 2026
82c6911
[build]
anngdinh Jun 17, 2026
3ccc47f
[build] deps: bump Go toolchain to 1.25.11 and golang.org/x/net to v0…
anngdinh Jun 17, 2026
69fed63
[build]
anngdinh Jun 17, 2026
f3959ff
[build] fix lint
anngdinh Jun 17, 2026
d24283b
[build] add role namespace
anngdinh Jun 17, 2026
d4022bf
add diagram
anngdinh Jun 17, 2026
d2647c6
[build] fix Gateway finalizer removal on already-deleted object
anngdinh Jun 22, 2026
89818d0
fix(lbc): apply pool member weight to load balancer
anngdinh Jun 24, 2026
62699c3
Merge pull request #13 from vngcloud/worktree-fix-pool-member-weight
vks-team Jun 25, 2026
0b46118
[build]
anngdinh Jun 25, 2026
703966c
[build] ci: pin govulncheck to v1.3.0 to avoid x/tools SSA panic on g…
anngdinh Jun 25, 2026
2208420
[build] ci: bump pinned actions to Node 24 runtime
anngdinh Jun 25, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/check-gitleaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2.3.9
- uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} # Only required for Organizations, not personal accounts.
21 changes: 14 additions & 7 deletions .github/workflows/check-govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ jobs:
if: contains(github.event.head_commit.message, '[build]')
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Scan for Vulnerabilities in Code
# Pinned to master HEAD: latest v1.0.4 tag transitively pulls actions/checkout@v4.1.1
# and actions/setup-go@v5.0.0 (Node 20). master HEAD pins them to v6.0.2 / v6.2.0 (Node 24).
# Switch back to a tagged release once upstream cuts v1.0.5+.
uses: golang/govulncheck-action@31f7c5463448f83528bd771c2d978d940080c9fd # master @ 2026-02-26
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-input: 1.25.10
go-package: ./...
go-version: 1.25.11
check-latest: true
- name: Scan for Vulnerabilities in Code
# NB: govulncheck is pinned to v1.3.0 (NOT @latest). v1.4.0 links
# golang.org/x/tools@v0.46.0, whose SSA call-graph builder panics on
# generic code under Go 1.25 ("ForEachElement called on type containing
# *types.TypeParam"), crashing the default -scan symbol mode. v1.3.0
# links x/tools@v0.44.0 and scans cleanly. The golang/govulncheck-action
# only installs @latest, so we invoke govulncheck directly instead.
# Revisit once upstream ships a fixed x/tools (then bump or drop the pin).
run: |
go install golang.org/x/vuln/cmd/govulncheck@v1.3.0
govulncheck -C . -format text ./...
6 changes: 3 additions & 3 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Log in to the GHCR
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to the vCR
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: vcr.vngcloud.vn
username: ${{ secrets.VCR_USER }}
Expand All @@ -45,7 +45,7 @@ jobs:
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
push: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Log in to the GHCR
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to the vCR HCM
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: vcr.vngcloud.vn
username: ${{ secrets.VCR_USER_PRO }}
password: ${{ secrets.VCR_PASSWORD_PRO }}

- name: Log in to the vCR HAN
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: vcr-han.vngcloud.vn
username: ${{ secrets.VCR_USER_HAN_PRO }}
Expand All @@ -53,7 +53,7 @@ jobs:
run: echo ${{ github.ref_name }}

- name: Build and push Docker image
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
push: true
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ linters:
linters:
- dupl
- lll
- path: "_test\\.go"
linters:
- unparam
settings:
revive:
rules:
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
.PHONY: sync-embedded-crds
sync-embedded-crds: ## Copy generated vks.vngcloud.vn CRDs into the binary-embedded location (pkg/k8s/apis/.../crds).
cp config/crd/bases/vks.vngcloud.vn_*.yaml pkg/k8s/apis/vks.vngcloud.vn/crds/
cp config/crd/bases/gateway.vks.vngcloud.vn_*.yaml pkg/k8s/apis/vks.vngcloud.vn/crds/ 2>/dev/null || true

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand All @@ -76,6 +77,12 @@ test: manifests generate fmt vet envtest ## Run tests.
test-e2e:
go test ./test/e2e/ -v -ginkgo.v

.PHONY: test-e2e-gateway # Run Gateway-API e2e against a REAL vngcloud cluster (opt-in).
# Requires: a real cluster reachable via KUBECONFIG, with the controller already
# deployed and --enable-gateway-api-alb set. Provisions and tears down real ALBs.
test-e2e-gateway:
RUN_GATEWAY_E2E=true go test ./test/e2e/gateway/ -v -ginkgo.v -timeout 20m

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter
$(GOLANGCI_LINT) run
Expand Down Expand Up @@ -112,7 +119,8 @@ build-pro:
.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go --log-level=debug \
--metrics-bind-address=:8080 --metrics-secure=false
--metrics-bind-address=:8080 --metrics-secure=false \
--disable-alb-gateway-controller=false --disable-nlb-gateway-controller=false
# --disable-service-controller \
# --disable-load-balancer-config-controller \
# --disable-ingress-controller \
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Application Load Balancers automatically.

- **L4 Load Balancing** — Network Load Balancers for `Service` resources of type `LoadBalancer`.
- **L7 Load Balancing** — Application Load Balancers driven by Kubernetes `Ingress` resources.
- **Gateway API** — Application Load Balancers driven by `Gateway`/`HTTPRoute`, and Network Load Balancers driven by `TCPRoute`/`UDPRoute`, customised via GEP-713 policy CRDs.
- **`LoadBalancerConfig` CRD** — Fine-grained control over listeners, pools, policies, and TLS certificates.
- **`NodeSecurityGroup` CRD** — Declarative management of node security-group rules.
- **`GlobalLoadBalancerConfig` / `VngcloudGlobalLoadBalancer` CRDs** — Multi-region traffic distribution.
Expand Down Expand Up @@ -143,7 +144,7 @@ spec:

More guides:

- [Service (L4)](docs/guide/service.md) · [Ingress (L7)](docs/guide/ingress.md)
- [Service (L4)](docs/guide/service.md) · [Ingress (L7)](docs/guide/ingress.md) · [Gateway API (ALB)](docs/guide/gateway-api.md) · [Gateway API (NLB)](docs/guide/gateway-nlb.md)
- [`LoadBalancerConfig` CRD](docs/guide/load-balancer-config.md)
- [`NodeSecurityGroup` CRD](docs/guide/node-security-group.md)
- [Global Load Balancer](docs/guide/global-load-balancer.md)
Expand All @@ -157,7 +158,9 @@ sources live under [`docs/`](docs/).

## Roadmap

- [ ] Gateway API support (design phase)
- [x] Gateway API support — Phase 1: ALB (`Gateway` + `HTTPRoute` + policy CRDs)
- [x] Gateway API Phase 2: NLB (`TCPRoute`/`UDPRoute`)
- [ ] Gateway API Phase 3+: `TLSRoute`, `GRPCRoute`, conformance
- [ ] End-to-end test suite
- [ ] Validating / mutating webhooks
- [ ] Out-of-band drift reconciliation (detect external load-balancer changes)
Expand Down
4 changes: 4 additions & 0 deletions api/gateway/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Package v1alpha1 contains API Schema definitions for the gateway.vks.vngcloud.vn v1alpha1 API group.
// +kubebuilder:object:generate=true
// +groupName=gateway.vks.vngcloud.vn
package v1alpha1
12 changes: 12 additions & 0 deletions api/gateway/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
GroupVersion = schema.GroupVersion{Group: "gateway.vks.vngcloud.vn", Version: "v1alpha1"}
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
AddToScheme = SchemeBuilder.AddToScheme
)
46 changes: 46 additions & 0 deletions api/gateway/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)

// LocalPolicyTargetReference is re-exported for convenience.
// +kubebuilder:object:generate=false
type LocalPolicyTargetReference = gwv1alpha2.LocalPolicyTargetReference

// LocalPolicyTargetReferenceWithSectionName is re-exported for convenience.
// +kubebuilder:object:generate=false
type LocalPolicyTargetReferenceWithSectionName = gwv1alpha2.LocalPolicyTargetReferenceWithSectionName

// PolicyAncestorStatus is re-exported for convenience.
// +kubebuilder:object:generate=false
type PolicyAncestorStatus = gwv1alpha2.PolicyAncestorStatus

// CommonPolicyStatus is the embedded ancestor-status block carried by every VKS policy CRD.
type CommonPolicyStatus struct {
// Ancestors records reconcile status per controller acting on this policy.
// +listType=atomic
// +kubebuilder:validation:MaxItems=16
Ancestors []PolicyAncestorStatus `json:"ancestors,omitempty"`
}

// PolicyConditionType collects the standard reasons used across all four VKS policy CRDs.
const (
PolicyConditionAccepted = "Accepted"
PolicyConditionProgrammed = "Programmed"

PolicyReasonAccepted = "Accepted"
PolicyReasonConflicted = "Conflicted"
PolicyReasonInvalid = "Invalid"
PolicyReasonTargetNotFound = "TargetNotFound"
PolicyReasonNoReadyController = "NoReadyController"
PolicyReasonProgrammed = "Programmed"
PolicyReasonPending = "Pending"
)

// CommonStatus is the common subset embedded into each policy's Status.
type CommonStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}
25 changes: 25 additions & 0 deletions api/gateway/v1alpha1/status_accessors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package v1alpha1

// GetCommonStatus / GetCommonPolicyStatus expose the embedded status blocks so
// a generic Direct-policy validator can read and write Conditions + Ancestors
// uniformly across the four policy CRDs.

func (p *VKSGatewayPolicy) GetCommonStatus() *CommonStatus { return &p.Status.CommonStatus }
func (p *VKSGatewayPolicy) GetCommonPolicyStatus() *CommonPolicyStatus {
return &p.Status.CommonPolicyStatus
}

func (p *VKSBackendPolicy) GetCommonStatus() *CommonStatus { return &p.Status.CommonStatus }
func (p *VKSBackendPolicy) GetCommonPolicyStatus() *CommonPolicyStatus {
return &p.Status.CommonPolicyStatus
}

func (p *VKSHealthCheckPolicy) GetCommonStatus() *CommonStatus { return &p.Status.CommonStatus }
func (p *VKSHealthCheckPolicy) GetCommonPolicyStatus() *CommonPolicyStatus {
return &p.Status.CommonPolicyStatus
}

func (p *VKSRoutePolicy) GetCommonStatus() *CommonStatus { return &p.Status.CommonStatus }
func (p *VKSRoutePolicy) GetCommonPolicyStatus() *CommonPolicyStatus {
return &p.Status.CommonPolicyStatus
}
88 changes: 88 additions & 0 deletions api/gateway/v1alpha1/vksbackendpolicy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

pkggw "github.com/vngcloud/vngcloud-load-balancer-controller/pkg/gateway"
)

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=vksbpolicy,categories=gateway-api
// +kubebuilder:metadata:labels=gateway.networking.k8s.io/policy=direct
// +kubebuilder:printcolumn:name="Targets",type=string,JSONPath=`.spec.targetRefs[*].name`
// +kubebuilder:printcolumn:name="Accepted",type=string,JSONPath=`.status.conditions[?(@.type=="Accepted")].status`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
type VKSBackendPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec VKSBackendPolicySpec `json:"spec,omitempty"`
Status VKSBackendPolicyStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
type VKSBackendPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VKSBackendPolicy `json:"items"`
}

type VKSBackendPolicySpec struct {
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
TargetRefs []LocalPolicyTargetReference `json:"targetRefs"`

// TargetType selects which addresses the controller resolves into pool
// members. "ip" puts pod IPs in the pool (works on flat networks /
// Cilium native routing). "instance" puts node IPs + nodePort in the
// pool (works on overlay networks where pod IPs aren't routable from
// the cloud LB). Default is auto-detected from the cluster CNI — same
// rule the Ingress controller uses today (Cilium overlay → instance,
// native routing → ip).
//
// This is a controller-side translation toggle, not a vngcloud LB API
// field; the resulting member IPs are what gets stored on the cloud
// pool. See design spec §1.6.
//
// +kubebuilder:validation:Enum=instance;ip
TargetType *string `json:"targetType,omitempty"`

// +kubebuilder:validation:Enum=ROUND_ROBIN;LEAST_CONNECTIONS;SOURCE_IP
PoolAlgorithm *string `json:"poolAlgorithm,omitempty"`

// Stickiness enables sticky sessions on the pool. The vngcloud LB API
// exposes only an on/off flag; cookie name and TTL are not configurable.
Stickiness *bool `json:"stickiness,omitempty"`

EnableTLSEncryption *bool `json:"enableTLSEncryption,omitempty"`
TargetNodeLabels map[string]string `json:"targetNodeLabels,omitempty"`
ManageDFPMembers *bool `json:"manageDFPMembers,omitempty"`

// ProxyProtocol makes the cloud LB pool speak HAProxy PROXY protocol to its
// members, so an L4 (NLB) backend such as an HAProxy/nginx ingress
// controller can recover the real client IP behind the load balancer.
// Honored only on the NLB (L4) path and only for TCP pools (UDP is
// ignored). Mirrors the Service controller's
// `vks.vngcloud.vn/enable-proxy-protocol` annotation.
ProxyProtocol *bool `json:"proxyProtocol,omitempty"`
}

type VKSBackendPolicyStatus struct {
CommonStatus `json:",inline"`
CommonPolicyStatus `json:",inline"`
}

// Matches reports whether this policy targets the given PolicyTarget.
func (p *VKSBackendPolicy) Matches(t pkggw.PolicyTarget) bool {
for _, ref := range p.Spec.TargetRefs {
if pkggw.TargetRefMatches(ref, p.Namespace, t) {
return true
}
}
return false
}

func init() {
SchemeBuilder.Register(&VKSBackendPolicy{}, &VKSBackendPolicyList{})
}
Loading
Loading