Skip to content

Commit

Permalink
Add service intentions as CRDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin Venkatesh committed Dec 7, 2021
1 parent 142107c commit 1965c1a
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- serviceintentions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceIntentions
metadata:
name: intentions
spec: {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../bases/exportedservices-default
- ../../../bases/partitions/exportedservices-default

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../bases/exportedservices-default
- ../../../bases/partitions/exportedservices-default

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- ../../../bases/partitions/intentions

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- ../../../bases/partitions/intentions

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- ../../../bases/partitions/intentions

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- ../../../bases/partitions/intentions

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../bases/exportedservices-secondary
- ../../../bases/partitions/exportedservices-secondary

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../bases/exportedservices-secondary
- ../../../bases/partitions/exportedservices-secondary

patchesStrategicMerge:
- patch.yaml
41 changes: 15 additions & 26 deletions acceptance/tests/partitions/partitions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,33 +604,22 @@ func TestPartitions(t *testing.T) {
k8s.CheckStaticServerConnectionFailing(t, clientClusterStaticClientOpts, "http://localhost:1234")
}

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)
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")
})
}
}

logger.Log(t, "checking that connection is successful")
Expand Down

0 comments on commit 1965c1a

Please sign in to comment.