Skip to content

Commit 9ba1ba4

Browse files
feat: Remove configmap that stores header based routes (#179)
* fix: do not use a configmap for managed routes Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> * fix: setWeight should not affect header based routing Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> ci: fixed lint format Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> * fix: match http behavior to be the same as grpc Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> * fix: use http route name match for header based routing Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> * fix: add k8s retries for all update operations Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> * test: added advanced header based tests Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> fix: Correctly locate main route (non-managed one) Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> test: Correctly locate main route (non-managed one) Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> test: removed duplicate tests Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> * test: make each test have its own services Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> * test: make each test have its own app labels Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> Revert "test: removed duplicate tests" This reverts commit f8fae68. test: remove duplicate tests Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com> --------- Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com>
1 parent 517eac5 commit 9ba1ba4

95 files changed

Lines changed: 1685 additions & 1025 deletions

File tree

Some content is hidden

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

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ define setup_cluster
2626
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/${GATEWAY_API_VERSION}/experimental-install.yaml --server-side=true --force-conflicts
2727
endef
2828

29-
define install_k8s_resources
30-
kubectl apply -f ./examples/traefik/stable.yml
31-
kubectl apply -f ./examples/traefik/canary.yml
32-
endef
33-
3429
.PHONY: install-dependencies
3530
install-dependencies:
3631
go mod download
@@ -66,7 +61,6 @@ ifeq (${IS_E2E_CLUSTER},)
6661
kind create cluster --name ${E2E_CLUSTER_NAME} --config ./test/cluster-setup/cluster-config.yml
6762
$(call add_helm_repo)
6863
$(call setup_cluster)
69-
$(call install_k8s_resources)
7064
endif
7165

7266
.PHONY: sanity-check-e2e

docs/installation.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ metadata:
105105
name: argo-rollouts-gateway-api-plugin
106106
rules:
107107
# Core API resources
108-
- apiGroups: [""]
109-
resources: ["configmaps"]
110-
verbs: ["get", "create", "update"]
111108
- apiGroups: [""]
112109
resources: ["services"]
113110
verbs: ["get"]
@@ -133,9 +130,6 @@ metadata:
133130
namespace: your-namespace
134131
rules:
135132
# Core API resources
136-
- apiGroups: [""]
137-
resources: ["configmaps"]
138-
verbs: ["get", "create", "update"]
139133
- apiGroups: [""]
140134
resources: ["services"]
141135
verbs: ["get"]
@@ -157,12 +151,12 @@ The plugin does NOT need permissions for:
157151
- **Gateways** - The plugin does not modify Gateway resources
158152
- **GatewayClasses** - The plugin does not interact with GatewayClasses
159153
- **Pods, Deployments, ReplicaSets** - The plugin does not manage workload resources
154+
- **ConfigMaps** - The plugin no longer uses a ConfigMap for state storage
160155
- **Delete permissions** - The plugin only adds/modifies/removes rules within routes, never deletes entire resources
161156
162157
If you want to further fine-tune permissions:
163158
164159
- [Label selector discovery](features/multiple-routes.md#automatic-route-discovery-with-label-selectors) requires `list` permissions; using explicit route names only requires `get`
165-
- If not using [header-based routing](features/header-based-routing.md), ConfigMap permissions can be omitted
166160

167161
## Configuration
168162

internal/defaults/defaults.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package defaults
22

33
const (
4-
ConfigMap = "argo-gatewayapi-configmap"
54
InProgressLabelKey = "rollouts.argoproj.io/gatewayapi-canary"
65
InProgressLabelValue = "in-progress"
76
)

internal/utils/common.go

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
package utils
22

33
import (
4-
"encoding/json"
5-
64
pluginTypes "github.com/argoproj/argo-rollouts/utils/plugin/types"
75
log "github.com/sirupsen/logrus"
8-
v1 "k8s.io/api/core/v1"
9-
kubeErrors "k8s.io/apimachinery/pkg/api/errors"
10-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
116
"k8s.io/client-go/rest"
127
"k8s.io/client-go/tools/clientcmd"
138
)
@@ -34,64 +29,3 @@ func SetupLog() *log.Entry {
3429
)
3530
return log.WithFields(log.Fields{"plugin": "trafficrouter"})
3631
}
37-
38-
func GetOrCreateConfigMap(name string, options CreateConfigMapOptions) (*v1.ConfigMap, error) {
39-
clientset := options.Clientset
40-
ctx := options.Ctx
41-
configMap, err := clientset.Get(ctx, name, metav1.GetOptions{})
42-
if err != nil && !kubeErrors.IsNotFound(err) {
43-
return nil, err
44-
}
45-
if err == nil {
46-
return configMap, err
47-
}
48-
configMap.Name = name
49-
configMap, err = clientset.Create(ctx, configMap, metav1.CreateOptions{})
50-
if err != nil {
51-
return nil, err
52-
}
53-
return configMap, err
54-
}
55-
56-
func GetConfigMapData(configMap *v1.ConfigMap, configMapKey string, destination any) error {
57-
if configMap.Data != nil && configMap.Data[configMapKey] != "" {
58-
err := json.Unmarshal([]byte(configMap.Data[configMapKey]), &destination)
59-
if err != nil {
60-
return err
61-
}
62-
}
63-
return nil
64-
}
65-
66-
func UpdateConfigMapData(configMap *v1.ConfigMap, configMapData any, options UpdateConfigMapOptions) error {
67-
clientset := options.Clientset
68-
rawConfigMapData, err := json.Marshal(configMapData)
69-
if err != nil {
70-
return err
71-
}
72-
if configMap.Data == nil {
73-
configMap.Data = make(map[string]string)
74-
}
75-
configMap.Data[options.ConfigMapKey] = string(rawConfigMapData)
76-
_, err = clientset.Update(options.Ctx, configMap, metav1.UpdateOptions{})
77-
return err
78-
}
79-
80-
func DoTransaction(logCtx *log.Entry, taskList ...Task) error {
81-
var err, reverseErr error
82-
for index, task := range taskList {
83-
err = task.Action()
84-
if err == nil {
85-
continue
86-
}
87-
logCtx.Error(err.Error())
88-
for i := index - 1; i > -1; i-- {
89-
reverseErr = taskList[i].ReverseAction()
90-
if reverseErr != nil {
91-
return reverseErr
92-
}
93-
}
94-
return err
95-
}
96-
return nil
97-
}

internal/utils/types.go

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

pkg/mocks/plugin.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package mocks
22

33
import (
4-
v1 "k8s.io/api/core/v1"
54
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
65

76
"sigs.k8s.io/gateway-api/apis/v1alpha2"
@@ -20,7 +19,6 @@ const (
2019
TCPRouteName = "argo-rollouts-tcp-route"
2120
TLSRouteName = "argo-rollouts-tls-route"
2221
RolloutNamespace = "default"
23-
ConfigMapName = "test-config"
2422
ManagedRouteName = "test-header-route"
2523
)
2624

@@ -312,10 +310,3 @@ var TLSRouteObj = v1alpha2.TLSRoute{
312310
},
313311
},
314312
}
315-
316-
var ConfigMapObj = v1.ConfigMap{
317-
ObjectMeta: metav1.ObjectMeta{
318-
Name: ConfigMapName,
319-
Namespace: RolloutNamespace,
320-
},
321-
}

pkg/plugin/errors.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ package plugin
33
const (
44
GatewayAPIUpdateError = "error updating Gateway API %q: %s"
55
GatewayAPIManifestError = "No routes configured. At least one of 'httpRoutes', 'grpcRoutes', 'tcpRoutes', 'tlsRoutes', 'httpRoute', 'grpcRoute', 'tcpRoute' or 'tlsRoute' must be set"
6-
HTTPRouteFieldIsEmptyError = "httpRoute field is empty. It has to be set to remove managed routes"
76
InvalidHeaderMatchTypeError = "invalid header match type"
87
BackendRefWasNotFoundInHTTPRouteError = "backendRef was not found in httpRoute"
98
BackendRefWasNotFoundInGRPCRouteError = "backendRef was not found in grpcRoute"
109
BackendRefWasNotFoundInTCPRouteError = "backendRef was not found in tcpRoute"
1110
BackendRefWasNotFoundInTLSRouteError = "backendRef was not found in tlsRoute"
1211
BackendRefListWasNotFoundInTCPRouteError = "backendRef list was not found in tcpRoute"
1312
BackendRefListWasNotFoundInTLSRouteError = "backendRef list was not found in tlsRoute"
14-
ManagedRouteMapEntryDeleteError = "can't delete key %q from managedRouteMap. The key %q is not in the managedRouteMap"
1513
)

0 commit comments

Comments
 (0)