From 249e5dcc5f715f923aa1a9e1310f89239060e9d8 Mon Sep 17 00:00:00 2001 From: Ashwin Venkatesh Date: Tue, 7 Dec 2021 14:01:25 -0500 Subject: [PATCH] Revert "Add service intentions as CRDs" This reverts commit 1965c1a6bd7c44ae27a0d82f6178682c01a24c27. --- .../exportedservices-default.yaml | 0 .../kustomization.yaml | 0 .../exportedservices-secondary.yaml | 0 .../kustomization.yaml | 0 .../partitions/intentions/kustomization.yaml | 2 - .../intentions/serviceintentions.yaml | 5 --- .../kustomization.yaml | 2 +- .../default-partition-ns1/kustomization.yaml | 2 +- .../kustomization.yaml | 5 --- .../intentions-default-default/patch.yaml | 13 ------ .../kustomization.yaml | 5 --- .../intentions-default-namespaces/patch.yaml | 13 ------ .../kustomization.yaml | 5 --- .../intentions-secondary-default/patch.yaml | 13 ------ .../kustomization.yaml | 5 --- .../patch.yaml | 13 ------ .../kustomization.yaml | 2 +- .../kustomization.yaml | 2 +- .../tests/partitions/partitions_test.go | 41 ++++++++++++------- 19 files changed, 30 insertions(+), 98 deletions(-) rename acceptance/tests/fixtures/bases/{partitions => }/exportedservices-default/exportedservices-default.yaml (100%) rename acceptance/tests/fixtures/bases/{partitions => }/exportedservices-default/kustomization.yaml (100%) rename acceptance/tests/fixtures/bases/{partitions => }/exportedservices-secondary/exportedservices-secondary.yaml (100%) rename acceptance/tests/fixtures/bases/{partitions => }/exportedservices-secondary/kustomization.yaml (100%) delete mode 100644 acceptance/tests/fixtures/bases/partitions/intentions/kustomization.yaml delete mode 100644 acceptance/tests/fixtures/bases/partitions/intentions/serviceintentions.yaml delete mode 100644 acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/kustomization.yaml delete mode 100644 acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/patch.yaml delete mode 100644 acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/kustomization.yaml delete mode 100644 acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/patch.yaml delete mode 100644 acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/kustomization.yaml delete mode 100644 acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/patch.yaml delete mode 100644 acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/kustomization.yaml delete mode 100644 acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/patch.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/exportedservices-default/exportedservices-default.yaml b/acceptance/tests/fixtures/bases/exportedservices-default/exportedservices-default.yaml similarity index 100% rename from acceptance/tests/fixtures/bases/partitions/exportedservices-default/exportedservices-default.yaml rename to acceptance/tests/fixtures/bases/exportedservices-default/exportedservices-default.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/exportedservices-default/kustomization.yaml b/acceptance/tests/fixtures/bases/exportedservices-default/kustomization.yaml similarity index 100% rename from acceptance/tests/fixtures/bases/partitions/exportedservices-default/kustomization.yaml rename to acceptance/tests/fixtures/bases/exportedservices-default/kustomization.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/exportedservices-secondary/exportedservices-secondary.yaml b/acceptance/tests/fixtures/bases/exportedservices-secondary/exportedservices-secondary.yaml similarity index 100% rename from acceptance/tests/fixtures/bases/partitions/exportedservices-secondary/exportedservices-secondary.yaml rename to acceptance/tests/fixtures/bases/exportedservices-secondary/exportedservices-secondary.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/exportedservices-secondary/kustomization.yaml b/acceptance/tests/fixtures/bases/exportedservices-secondary/kustomization.yaml similarity index 100% rename from acceptance/tests/fixtures/bases/partitions/exportedservices-secondary/kustomization.yaml rename to acceptance/tests/fixtures/bases/exportedservices-secondary/kustomization.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/intentions/kustomization.yaml b/acceptance/tests/fixtures/bases/partitions/intentions/kustomization.yaml deleted file mode 100644 index aff115793a..0000000000 --- a/acceptance/tests/fixtures/bases/partitions/intentions/kustomization.yaml +++ /dev/null @@ -1,2 +0,0 @@ -resources: - - serviceintentions.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/intentions/serviceintentions.yaml b/acceptance/tests/fixtures/bases/partitions/intentions/serviceintentions.yaml deleted file mode 100644 index 48a642dfa4..0000000000 --- a/acceptance/tests/fixtures/bases/partitions/intentions/serviceintentions.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: {} diff --git a/acceptance/tests/fixtures/cases/crd-partitions/default-partition-default/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/default-partition-default/kustomization.yaml index 6055280660..499fdc5bc1 100644 --- a/acceptance/tests/fixtures/cases/crd-partitions/default-partition-default/kustomization.yaml +++ b/acceptance/tests/fixtures/cases/crd-partitions/default-partition-default/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - ../../../bases/partitions/exportedservices-default + - ../../../bases/exportedservices-default patchesStrategicMerge: - patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/default-partition-ns1/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/default-partition-ns1/kustomization.yaml index 6055280660..499fdc5bc1 100644 --- a/acceptance/tests/fixtures/cases/crd-partitions/default-partition-ns1/kustomization.yaml +++ b/acceptance/tests/fixtures/cases/crd-partitions/default-partition-ns1/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - ../../../bases/partitions/exportedservices-default + - ../../../bases/exportedservices-default patchesStrategicMerge: - patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/kustomization.yaml deleted file mode 100644 index b3784897f8..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: - - ../../../bases/partitions/intentions - -patchesStrategicMerge: -- patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/patch.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/patch.yaml deleted file mode 100644 index df1976c7b2..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/patch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: - destination: - name: static-server - namespace: default - sources: - - name: static-client - namespace: default - partition: secondary - action: allow diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/kustomization.yaml deleted file mode 100644 index b3784897f8..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: - - ../../../bases/partitions/intentions - -patchesStrategicMerge: -- patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/patch.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/patch.yaml deleted file mode 100644 index e87ab17ba3..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/patch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: - destination: - name: static-server - namespace: ns1 - sources: - - name: static-client - namespace: ns2 - partition: secondary - action: allow diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/kustomization.yaml deleted file mode 100644 index b3784897f8..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: - - ../../../bases/partitions/intentions - -patchesStrategicMerge: -- patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/patch.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/patch.yaml deleted file mode 100644 index b37311357d..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/patch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: - destination: - name: static-server - namespace: default - sources: - - name: static-client - namespace: default - partition: default - action: allow diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/kustomization.yaml deleted file mode 100644 index b3784897f8..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: - - ../../../bases/partitions/intentions - -patchesStrategicMerge: -- patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/patch.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/patch.yaml deleted file mode 100644 index b908e66970..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/patch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: - destination: - name: static-server - namespace: ns1 - sources: - - name: static-client - namespace: ns2 - partition: default - action: allow diff --git a/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-default/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-default/kustomization.yaml index a75dcf8e40..5a9c8412aa 100644 --- a/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-default/kustomization.yaml +++ b/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-default/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - ../../../bases/partitions/exportedservices-secondary + - ../../../bases/exportedservices-secondary patchesStrategicMerge: - patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-ns1/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-ns1/kustomization.yaml index a75dcf8e40..5a9c8412aa 100644 --- a/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-ns1/kustomization.yaml +++ b/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-ns1/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - ../../../bases/partitions/exportedservices-secondary + - ../../../bases/exportedservices-secondary patchesStrategicMerge: - patch.yaml diff --git a/acceptance/tests/partitions/partitions_test.go b/acceptance/tests/partitions/partitions_test.go index 1adad75aff..691a4d52e4 100644 --- a/acceptance/tests/partitions/partitions_test.go +++ b/acceptance/tests/partitions/partitions_test.go @@ -604,22 +604,33 @@ func TestPartitions(t *testing.T) { k8s.CheckStaticServerConnectionFailing(t, clientClusterStaticClientOpts, "http://localhost:1234") } - logger.Log(t, "creating intention") - if c.destinationNamespace == defaultNamespace { - k8s.KubectlApplyK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-default-default") - k8s.KubectlApplyK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-secondary-default") - helpers.Cleanup(t, cfg.NoCleanupOnFailure, func() { - k8s.KubectlDeleteK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-default-default") - k8s.KubectlDeleteK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-secondary-default") - }) - } else { - k8s.KubectlApplyK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-default-namespaces") - k8s.KubectlApplyK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-secondary-namespaces") - helpers.Cleanup(t, cfg.NoCleanupOnFailure, func() { - k8s.KubectlDeleteK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-default-namespaces") - k8s.KubectlDeleteK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-secondary-namespaces") - }) + intention := &api.ServiceIntentionsConfigEntry{ + Name: staticServerName, + Kind: api.ServiceIntentions, + Namespace: staticServerNamespace, + Sources: []*api.SourceIntention{ + { + Name: staticClientName, + Namespace: staticClientNamespace, + Action: api.IntentionActionAllow, + }, + }, + } + + // Set the destination namespace to be the same + // unless mirrorK8S is true. + if !c.mirrorK8S { + intention.Namespace = c.destinationNamespace + intention.Sources[0].Namespace = c.destinationNamespace } + + logger.Log(t, "creating intention") + intention.Sources[0].Partition = secondaryPartition + _, _, err := consulClient.ConfigEntries().Set(intention, &api.WriteOptions{Partition: defaultPartition}) + require.NoError(t, err) + intention.Sources[0].Partition = defaultPartition + _, _, err = consulClient.ConfigEntries().Set(intention, &api.WriteOptions{Partition: secondaryPartition}) + require.NoError(t, err) } logger.Log(t, "checking that connection is successful")