Skip to content

Commit 57e3db8

Browse files
aa1exVendjin
andauthored
Virtual service management via UI (WIP) + Multiple Access logs (#189)
Virtual service management via UI (WIP) + Multiple Access logs --------- Signed-off-by: Aleksandr Aleksandrov <aaleksandrov.cy@gmail.com> Co-authored-by: AndreyKS <andruxa325@gmail.com>
1 parent 5267673 commit 57e3db8

File tree

419 files changed

+34619
-7713
lines changed

Some content is hidden

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

419 files changed

+34619
-7713
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ RUN go mod download
1515
COPY cmd/main.go cmd/main.go
1616
COPY api/ api/
1717
COPY internal/ internal/
18-
COPY docs/cacheRestAPI docs/cacheRestAPI
18+
COPY pkg/ pkg/
19+
COPY docs/api/cacheRestAPI docs/api/cacheRestAPI
1920

2021
# Build
2122
# the GOARCH has not a default value to allow the binary be built according to the host where the command

Makefile

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ UI_IMG ?= $(UI_IMG_WITHOUT_TAG):$(TAG)
1010

1111
DEPLOY_TIMEOUT ?= 5m
1212

13+
PROM_OPERATOR_VERSION ?= v0.77.1
14+
1315
# REGISTRY is the image registry to use for build and push image targets.
1416
REGISTRY ?= docker.io/kaasops
1517

@@ -251,6 +253,7 @@ endef
251253
## HELM
252254

253255
URL=https://kaasops.github.io/envoy-xds-controller/helm
256+
AUTH_ENABLED=false
254257

255258
.PHONY: helm-lint
256259
helm-lint:
@@ -269,12 +272,30 @@ helm-index:
269272
.PHONY: helm-deploy-local
270273
helm-deploy-local: manifests set-local## Install Envoy xDS Controller into the local Kubernetes cluster specified in ~/.kube/config.
271274
@$(LOG_TARGET)
272-
helm install exc --set 'watchNamespaces={default}' --set image.repository=$(IMG_WITHOUT_TAG) --set image.tag=$(TAG) --set ui.enabled=true --set cacheAPI.enabled=true --set ui.image.repository=$(UI_IMG_WITHOUT_TAG) --set ui.image.tag=$(TAG) --namespace envoy-xds-controller --create-namespace ./helm/charts/envoy-xds-controller --debug --timeout='$(DEPLOY_TIMEOUT)' --wait
275+
helm install exc --set metrics.address=:8443 \
276+
--set metrics.secure=false \
277+
--set development=true \
278+
--set auth.enabled=$(AUTH_ENABLED) \
279+
--set 'watchNamespaces={default}' \
280+
--set image.repository=$(IMG_WITHOUT_TAG) \
281+
--set image.tag=$(TAG) \
282+
--set ui.enabled=true \
283+
--set cacheAPI.enabled=true \
284+
--set ui.image.repository=$(UI_IMG_WITHOUT_TAG) \
285+
--set ui.image.tag=$(TAG) \
286+
--set resourceAPI.enabled=true \
287+
--namespace envoy-xds-controller \
288+
--create-namespace ./helm/charts/envoy-xds-controller \
289+
--debug --timeout='$(DEPLOY_TIMEOUT)' --wait
273290

274291
.PHONY: set-local
275292
set-local:
276293
$(eval REGISTRY := $(LOCAL_REGISTRY))
277294

295+
.PHONY: set-auth-env
296+
set-auth-env:
297+
$(eval AUTH_ENABLED := true)
298+
278299
.PHONY: debug-local
279300
debug-local: set-local
280301
@echo $(REGISTRY)
@@ -289,4 +310,71 @@ kr:
289310

290311
.PHONY: kd
291312
kd:
292-
kind delete cluster
313+
kind delete cluster
314+
315+
.PHONY: dev-apply-resources
316+
dev-apply-resources:
317+
kubectl -n envoy-xds-controller apply -f dev/testdata
318+
319+
.PHONY: dev-delete-resources
320+
dev-delete-resources:
321+
kubectl -n envoy-xds-controller delete -f dev/testdata
322+
323+
.PHONY: helm-deploy-backend-local
324+
helm-deploy-backend-local: manifests set-local## Install Envoy xDS Controller into the local Kubernetes cluster specified in ~/.kube/config.
325+
@$(LOG_TARGET)
326+
helm install exc --set metrics.address=:8443 \
327+
--set 'watchNamespaces={default}' \
328+
--set image.repository=$(IMG_WITHOUT_TAG) \
329+
--set image.tag=$(TAG) \
330+
--set cacheAPI.enabled=true \
331+
--set resourceAPI.enabled=true \
332+
--namespace envoy-xds-controller \
333+
--create-namespace ./helm/charts/envoy-xds-controller \
334+
--debug --timeout='$(DEPLOY_TIMEOUT)' --wait
335+
336+
.PHONY: dev-backend
337+
dev-backend: set-local docker-build docker-push install-prometheus helm-deploy-backend-local
338+
339+
.PHONY: deploy-e2e
340+
deploy-e2e: manifests
341+
helm install exc-e2e --set metrics.address=:8443 \
342+
--set 'watchNamespaces={default}' \
343+
--set image.repository=$(IMG_WITHOUT_TAG) \
344+
--set image.tag=$(TAG) \
345+
--set cacheAPI.enabled=true \
346+
--set resourceAPI.enabled=true \
347+
--namespace envoy-xds-controller \
348+
--create-namespace ./helm/charts/envoy-xds-controller \
349+
--debug --timeout='$(DEPLOY_TIMEOUT)' --wait
350+
351+
.PHONY: undeploy-e2e
352+
undeploy-e2e:
353+
helm uninstall -n envoy-xds-controller exc-e2e
354+
355+
.PHONY: install-prometheus
356+
install-prometheus:
357+
kubectl create -f https://github.com/prometheus-operator/prometheus-operator/releases/download/$(PROM_OPERATOR_VERSION)/bundle.yaml
358+
359+
.PHONY: uninstall-prometheus
360+
uninstall-prometheus:
361+
kubectl delete -f https://github.com/prometheus-operator/prometheus-operator/releases/download/$(PROM_OPERATOR_VERSION)/bundle.yaml
362+
363+
.PHONY: bufgen
364+
bufgen:
365+
buf generate
366+
367+
.PHONY: dev-auth
368+
dev-auth:
369+
bash scripts/dev-auth.sh
370+
371+
.PHONY: dev-local-with-auth
372+
dev-local-with-auth: dev-auth set-auth-env install-prometheus dev-local
373+
374+
.PHONY: helm-template
375+
helm-template:
376+
helm template exc -n envoy-xds-controller ./helm/charts/envoy-xds-controller/
377+
378+
.PHONY: dev-envoy
379+
dev-envoy:
380+
kubectl apply -f dev/envoy

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
# envoy-xds-controller
2-
// TODO(user): Add simple overview of use/purpose
2+
3+
A Kubernetes-native control plane for Envoy proxies that provides dynamic configuration management through the xDS API.
34

45
## Description
5-
// TODO(user): An in-depth paragraph about your project and overview of use
6+
7+
Envoy xDS Controller is a Kubernetes controller that manages Envoy proxy configurations through the xDS API. It allows defining Envoy configurations as Kubernetes Custom Resources (CRs) and automatically transforms them into Envoy configurations, which are delivered to proxies via the xDS protocol in real-time.
8+
9+
Key features:
10+
- Full support for Envoy xDS v3 API (LDS, RDS, CDS, EDS)
11+
- Kubernetes-native integration with controller-runtime
12+
- Dynamic configuration updates without proxy restarts
13+
- Authentication and authorization with OIDC and RBAC
14+
- Templating system for configuration reuse
15+
- Web UI for configuration management
616

717
## Getting Started
818

@@ -90,7 +100,27 @@ kubectl apply -f https://raw.githubusercontent.com/<org>/envoy-xds-controller/<t
90100
```
91101

92102
## Contributing
93-
// TODO(user): Add detailed information on how you would like others to contribute to this project
103+
104+
We welcome contributions to the Envoy xDS Controller project! Here's how you can contribute:
105+
106+
1. **Code Contributions**:
107+
- Fork the repository
108+
- Create a feature branch (`git checkout -b feature/amazing-feature`)
109+
- Commit your changes (`git commit -m 'Add some amazing feature'`)
110+
- Push to the branch (`git push origin feature/amazing-feature`)
111+
- Open a Pull Request
112+
113+
2. **Bug Reports and Feature Requests**:
114+
- Use the GitHub issue tracker to report bugs or request features
115+
116+
3. **Development Environment**:
117+
- See the [development documentation](docs/development.md) for setting up your development environment
118+
- Check [contributing guidelines](docs/contributing/development.md) for webhook setup
119+
120+
4. **Testing**:
121+
- Add tests for new features
122+
- Run existing tests with `make test`
123+
- Run end-to-end tests with `make test-e2e`
94124

95125
**NOTE:** Run `make help` for more information on all potential `make` targets
96126

@@ -111,4 +141,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
111141
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
112142
See the License for the specific language governing permissions and
113143
limitations under the License.
114-

api/v1alpha1/accesslogconfig_methods.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,15 @@ func (a *AccessLogConfig) IsEqual(other *AccessLogConfig) bool {
121121

122122
return true
123123
}
124+
125+
func (a *AccessLogConfig) GetAccessGroup() string {
126+
accessGroup := a.GetLabels()[LabelAccessGroup]
127+
if accessGroup == "" {
128+
return GeneralAccessGroup
129+
}
130+
return accessGroup
131+
}
132+
133+
func (a *AccessLogConfig) GetDescription() string {
134+
return a.Annotations[annotationDescription]
135+
}

api/v1alpha1/cluster_methods.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ func (c *Cluster) IsEqual(other *Cluster) bool {
6060
}
6161
return true
6262
}
63+
64+
func (c *Cluster) GetDescription() string {
65+
return c.Annotations[annotationDescription]
66+
}

api/v1alpha1/httpfilter_methods.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
hcmv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
88
"github.com/kaasops/envoy-xds-controller/internal/protoutil"
9+
"sigs.k8s.io/yaml"
910
)
1011

1112
func (h *HttpFilter) UnmarshalV3() ([]*hcmv3.HttpFilter, error) {
@@ -74,3 +75,34 @@ func (h *HttpFilter) IsEqual(other *HttpFilter) bool {
7475
}
7576
return true
7677
}
78+
79+
func (h *HttpFilter) GetAccessGroup() string {
80+
accessGroup := h.GetLabels()[LabelAccessGroup]
81+
if accessGroup == "" {
82+
return GeneralAccessGroup
83+
}
84+
return accessGroup
85+
}
86+
87+
func (h *HttpFilter) GetDescription() string {
88+
return h.Annotations[annotationDescription]
89+
}
90+
91+
func (h *HttpFilter) Raw() []byte {
92+
if h == nil || len(h.Spec) == 0 {
93+
return nil
94+
}
95+
items := make([]any, 0, len(h.Spec))
96+
for _, spec := range h.Spec {
97+
var httpFilterMap map[string]interface{}
98+
if err := yaml.Unmarshal(spec.Raw, &httpFilterMap); err != nil {
99+
return nil
100+
}
101+
items = append(items, httpFilterMap)
102+
}
103+
data, err := json.Marshal(items)
104+
if err != nil {
105+
return nil
106+
}
107+
return data
108+
}

api/v1alpha1/listener_methods.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,15 @@ func (l *Listener) IsEqual(other *Listener) bool {
4242
}
4343
return bytes.Equal(l.Spec.Raw, other.Spec.Raw)
4444
}
45+
46+
func (l *Listener) GetAccessGroup() string {
47+
accessGroup := l.GetLabels()[LabelAccessGroup]
48+
if accessGroup == "" {
49+
return GeneralAccessGroup
50+
}
51+
return accessGroup
52+
}
53+
54+
func (l *Listener) GetDescription() string {
55+
return l.Annotations[annotationDescription]
56+
}

api/v1alpha1/policy_methods.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,15 @@ func (p *Policy) IsEqual(other *Policy) bool {
5454
}
5555
return bytes.Equal(p.Spec.Raw, other.Spec.Raw)
5656
}
57+
58+
func (p *Policy) GetAccessGroup() string {
59+
accessGroup := p.GetLabels()[LabelAccessGroup]
60+
if accessGroup == "" {
61+
return GeneralAccessGroup
62+
}
63+
return accessGroup
64+
}
65+
66+
func (p *Policy) GetDescription() string {
67+
return p.Annotations[annotationDescription]
68+
}

api/v1alpha1/route_methods.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ package v1alpha1
33
import (
44
"bytes"
55

6+
"encoding/json"
7+
68
routev3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
79
"github.com/kaasops/envoy-xds-controller/internal/protoutil"
10+
"sigs.k8s.io/yaml"
811
)
912

1013
func (r *Route) UnmarshalV3() ([]*routev3.Route, error) {
@@ -57,3 +60,34 @@ func (r *Route) IsEqual(other *Route) bool {
5760
}
5861
return true
5962
}
63+
64+
func (r *Route) GetAccessGroup() string {
65+
accessGroup := r.GetLabels()[LabelAccessGroup]
66+
if accessGroup == "" {
67+
return GeneralAccessGroup
68+
}
69+
return accessGroup
70+
}
71+
72+
func (r *Route) GetDescription() string {
73+
return r.Annotations[annotationDescription]
74+
}
75+
76+
func (r *Route) Raw() []byte {
77+
if r == nil || len(r.Spec) == 0 {
78+
return nil
79+
}
80+
items := make([]any, 0, len(r.Spec))
81+
for _, spec := range r.Spec {
82+
var routeMap map[string]interface{}
83+
if err := yaml.Unmarshal(spec.Raw, &routeMap); err != nil {
84+
return nil
85+
}
86+
items = append(items, routeMap)
87+
}
88+
data, err := json.Marshal(items)
89+
if err != nil {
90+
return nil
91+
}
92+
return data
93+
}

api/v1alpha1/shared_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package v1alpha1
22

3-
const AnnotationSecretDomains = "envoy.kaasops.io/domains"
3+
const AnnotationSecretDomains = "envoy.kaasops.io/domains" // TODO: make private, access via getter
4+
const annotationDescription = "envoy.kaasops.io/description"
5+
const GeneralAccessGroup = "general"
46

57
type Message string
68

0 commit comments

Comments
 (0)