Skip to content

Commit

Permalink
Rename to exported services (#902)
Browse files Browse the repository at this point in the history
* Rename partitionExports to exportedServices
- Update anonymous token job to not run in non-default partitions. The current implementation breaks against the latest consul version.
* Update consul API where exportedservices are renamed.
  • Loading branch information
thisisnotashwin authored Dec 8, 2021
1 parent aea9efe commit 6408674
Show file tree
Hide file tree
Showing 109 changed files with 379 additions and 1,487 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ FEATURES:
* `global.tls.enableAutoEncryption=true` is required for TLS support.
* If TLS is enabled in Vault, `global.secretsBackend.vault.ca` must be provided and should reference a Kube secret
which holds a copy of the Vault CA cert.
* Add boolean metric to merged metrics response `consul_merged_service_metrics_success` to indicate if service metrics were
scraped successfully. [[GH-551](https://github.com/hashicorp/consul-k8s/pull/551)]
* Helm
* Rename `PartitionExports` CRD to `ExportedServices`. [[GH-902](https://github.com/hashicorp/consul-k8s/pull/902)]

IMPROVEMENTS:
* CLI
* Pre-check in the `install` command to verify the correct license secret exists when using an enterprise Consul image. [[GH-875](https://github.com/hashicorp/consul-k8s/pull/875)]
* Control Plane
* Add a label "managed-by" to every secret the control-plane creates. Only delete said secrets on an uninstall. [[GH-835](https://github.com/hashicorp/consul-k8s/pull/835)]
Expand Down
2 changes: 1 addition & 1 deletion acceptance/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/gruntwork-io/terratest v0.31.2
github.com/hashicorp/consul-k8s/control-plane v0.0.0-20211118191758-929940b5ab51
github.com/hashicorp/consul/api v1.10.1-0.20211116182834-e6956893fb6f
github.com/hashicorp/consul/api v1.10.1-0.20211206193229-9b44861ce4bc
github.com/hashicorp/consul/sdk v0.8.0
github.com/hashicorp/vault/api v1.2.0
github.com/stretchr/testify v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions acceptance/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ github.com/gruntwork-io/terratest v0.31.2/go.mod h1:EEgJie28gX/4AD71IFqgMj6e99KP
github.com/hashicorp/consul-k8s/control-plane v0.0.0-20211118191758-929940b5ab51 h1:Km6RYuAsJVVu3gipkTWF1SVYuvSJrksBtT89rO4hcdA=
github.com/hashicorp/consul-k8s/control-plane v0.0.0-20211118191758-929940b5ab51/go.mod h1:+Ay3RL0eZdI0wgT193r+EJTOk9cSn1WUlvBvk6Lfnmo=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/api v1.10.1-0.20211116182834-e6956893fb6f h1:fBBh4412td7nBzqyLkpGTH5dWycPs8p7Yg/Dy8VQjVU=
github.com/hashicorp/consul/api v1.10.1-0.20211116182834-e6956893fb6f h1:fBBh4412td7nBzqyLkpGTH5dWycPs8p7Yg/Dy8VQjVU=
github.com/hashicorp/consul/api v1.10.1-0.20211116182834-e6956893fb6f/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0=
github.com/hashicorp/consul/api v1.10.1-0.20211116182834-e6956893fb6f/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0=
github.com/hashicorp/consul/api v1.10.1-0.20211206193229-9b44861ce4bc h1:tUgL1cinAFDtidyKqgsJzlxLkEi9atLmN6j8kgCr17Q=
github.com/hashicorp/consul/api v1.10.1-0.20211206193229-9b44861ce4bc/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRrZHTVU=
github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms=
Expand Down
26 changes: 13 additions & 13 deletions acceptance/tests/controller/controller_namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestControllerNamespaces(t *testing.T) {
ctx := suite.Environment().DefaultContext(t)

helmValues := map[string]string{
"global.image": "hashicorp/consul-enterprise:1.11.0-ent-beta3",
"global.image": "ashwinvenkatesh/consul@sha256:4be07b9c90fc590827ad72328da332c2003a14d237df317a0c977817f6fdaf0b",

"global.enableConsulNamespaces": "true",
"global.adminPartitions.enabled": "true",
Expand Down Expand Up @@ -156,12 +156,12 @@ func TestControllerNamespaces(t *testing.T) {
require.True(r, ok, "could not cast to ProxyConfigEntry")
require.Equal(r, api.MeshGatewayModeLocal, proxyDefaultEntry.MeshGateway.Mode)

// partition-exports
entry, _, err = consulClient.ConfigEntries().Get(api.PartitionExports, "default", defaultOpts)
// exported-services
entry, _, err = consulClient.ConfigEntries().Get(api.ExportedServices, "default", defaultOpts)
require.NoError(r, err)
partitionExportsEntry, ok := entry.(*api.PartitionExportsConfigEntry)
require.True(r, ok, "could not cast to PartitionExportsConfigEntry")
require.Equal(r, "frontend", partitionExportsEntry.Services[0].Name)
exportedServicesEntry, ok := entry.(*api.ExportedServicesConfigEntry)
require.True(r, ok, "could not cast to ExportedServicesConfigEntry")
require.Equal(r, "frontend", exportedServicesEntry.Services[0].Name)

// mesh
entry, _, err = consulClient.ConfigEntries().Get(api.MeshConfig, "mesh", defaultOpts)
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestControllerNamespaces(t *testing.T) {

logger.Log(t, "patching partition-exports custom resource")
patchServiceName := "backend"
k8s.RunKubectl(t, ctx.KubectlOptions(t), "patch", "-n", KubeNS, "partitionexports", "default", "-p", fmt.Sprintf(`{"spec":{"services":[{"name": "%s", "namespace": "front", "consumers":[{"partition": "foo"}]}]}}`, patchServiceName), "--type=merge")
k8s.RunKubectl(t, ctx.KubectlOptions(t), "patch", "-n", KubeNS, "exportedservices", "default", "-p", fmt.Sprintf(`{"spec":{"services":[{"name": "%s", "namespace": "front", "consumers":[{"partition": "foo"}]}]}}`, patchServiceName), "--type=merge")

logger.Log(t, "patching mesh custom resource")
k8s.RunKubectl(t, ctx.KubectlOptions(t), "patch", "-n", KubeNS, "mesh", "mesh", "-p", fmt.Sprintf(`{"spec":{"transparentProxy":{"meshDestinationsOnly": %t}}}`, false), "--type=merge")
Expand Down Expand Up @@ -279,11 +279,11 @@ func TestControllerNamespaces(t *testing.T) {
require.Equal(r, api.MeshGatewayModeRemote, proxyDefaultsEntry.MeshGateway.Mode)

// partition-exports
entry, _, err = consulClient.ConfigEntries().Get(api.PartitionExports, "default", defaultOpts)
entry, _, err = consulClient.ConfigEntries().Get(api.ExportedServices, "default", defaultOpts)
require.NoError(r, err)
partitionExportsEntry, ok := entry.(*api.PartitionExportsConfigEntry)
require.True(r, ok, "could not cast to PartitionExportsConfigEntry")
require.Equal(r, "backend", partitionExportsEntry.Services[0].Name)
exportedServicesEntry, ok := entry.(*api.ExportedServicesConfigEntry)
require.True(r, ok, "could not cast to ExportedServicesConfigEntry")
require.Equal(r, "backend", exportedServicesEntry.Services[0].Name)

// mesh
entry, _, err = consulClient.ConfigEntries().Get(api.MeshConfig, "mesh", defaultOpts)
Expand Down Expand Up @@ -343,7 +343,7 @@ func TestControllerNamespaces(t *testing.T) {
k8s.RunKubectl(t, ctx.KubectlOptions(t), "delete", "-n", KubeNS, "proxydefaults", "global")

logger.Log(t, "deleting partition-exports custom resource")
k8s.RunKubectl(t, ctx.KubectlOptions(t), "delete", "-n", KubeNS, "partitionexports", "default")
k8s.RunKubectl(t, ctx.KubectlOptions(t), "delete", "-n", KubeNS, "exportedservices", "default")

logger.Log(t, "deleting mesh custom resource")
k8s.RunKubectl(t, ctx.KubectlOptions(t), "delete", "-n", KubeNS, "mesh", "mesh")
Expand Down Expand Up @@ -381,7 +381,7 @@ func TestControllerNamespaces(t *testing.T) {
require.Contains(r, err.Error(), "404 (Config entry not found")

// partition-exports
_, _, err = consulClient.ConfigEntries().Get(api.PartitionExports, "default", defaultOpts)
_, _, err = consulClient.ConfigEntries().Get(api.ExportedServices, "default", defaultOpts)
require.Error(r, err)
require.Contains(r, err.Error(), "404 (Config entry not found")

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: PartitionExports
kind: ExportedServices
metadata:
name: default
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- exportedservices-default.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: PartitionExports
kind: ExportedServices
metadata:
name: secondary
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- exportedservices-secondary.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../bases/admin-partitions
- ../../../bases/exportedservices-default

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: PartitionExports
kind: ExportedServices
metadata:
name: default
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../bases/admin-partitions
- ../../../bases/exportedservices-default

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: PartitionExports
kind: ExportedServices
metadata:
name: default
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../bases/admin-partitions
- ../../../bases/exportedservices-secondary

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: PartitionExports
kind: ExportedServices
metadata:
name: secondary
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../bases/admin-partitions
- ../../../bases/exportedservices-secondary

patchesStrategicMerge:
- patch.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: PartitionExports
kind: ExportedServices
metadata:
name: secondary
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: PartitionExports
kind: ExportedServices
metadata:
name: default
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
resources:
- ../../bases/crds-oss
- partitionexports.yaml
- exportedservices.yaml
6 changes: 3 additions & 3 deletions acceptance/tests/partitions/partitions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestPartitions(t *testing.T) {

serverHelmValues := map[string]string{
"global.datacenter": "dc1",
"global.image": "hashicorp/consul-enterprise:1.11.0-ent-beta3",
"global.image": "ashwinvenkatesh/consul@sha256:dce7a25b9e15271d8102a0f14fae71af0b9c789bafd8cbe4a7d0f8c34abe0296",

"global.adminPartitions.enabled": "true",
"global.enableConsulNamespaces": "true",
Expand Down Expand Up @@ -192,7 +192,7 @@ func TestPartitions(t *testing.T) {
// Create client cluster.
clientHelmValues := map[string]string{
"global.datacenter": "dc1",
"global.image": "hashicorp/consul-enterprise:1.11.0-ent-beta3",
"global.image": "ashwinvenkatesh/consul@sha256:dce7a25b9e15271d8102a0f14fae71af0b9c789bafd8cbe4a7d0f8c34abe0296",
"global.enabled": "false",

"global.tls.enabled": "true",
Expand Down Expand Up @@ -535,7 +535,7 @@ func TestPartitions(t *testing.T) {
require.NoError(t, err)
require.Len(t, services, 1)

logger.Log(t, "creating partition exports")
logger.Log(t, "creating exported services")
if c.destinationNamespace == defaultNamespace {
k8s.KubectlApplyK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/default-partition-default")
k8s.KubectlApplyK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/secondary-partition-default")
Expand Down
4 changes: 2 additions & 2 deletions charts/consul/templates/controller-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rules:
- serviceresolvers
- proxydefaults
- meshes
- partitionexports
- exportedservices
- servicerouters
- servicesplitters
- serviceintentions
Expand All @@ -38,7 +38,7 @@ rules:
- serviceresolvers/status
- proxydefaults/status
- meshes/status
- partitionexports/status
- exportedservices/status
- servicerouters/status
- servicesplitters/status
- serviceintentions/status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,25 @@ webhooks:
resources:
- terminatinggateways
sideEffects: None
- clientConfig:
service:
name: {{ template "consul.fullname" . }}-controller-webhook
namespace: {{ .Release.Namespace }}
path: /mutate-v1alpha1-exportedservices
failurePolicy: Fail
admissionReviewVersions:
- "v1beta1"
- "v1"
name: mutate-exportedservices.consul.hashicorp.com
rules:
- apiGroups:
- consul.hashicorp.com
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- exportedservices
sideEffects: None
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.0
creationTimestamp: null
name: partitionexports.consul.hashicorp.com
name: exportedservices.consul.hashicorp.com
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
Expand All @@ -16,10 +16,10 @@ metadata:
spec:
group: consul.hashicorp.com
names:
kind: PartitionExports
listKind: PartitionExportsList
plural: partitionexports
singular: partitionexports
kind: ExportedServices
listKind: ExportedServicesList
plural: exportedservices
singular: exportedservices
scope: Namespaced
versions:
- additionalPrinterColumns:
Expand All @@ -38,7 +38,7 @@ spec:
name: v1alpha1
schema:
openAPIV3Schema:
description: PartitionExports is the Schema for the partitionexports API
description: ExportedServices is the Schema for the exportedservices API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -53,7 +53,7 @@ spec:
metadata:
type: object
spec:
description: PartitionExportsSpec defines the desired state of PartitionExports
description: ExportedServicesSpec defines the desired state of ExportedServices
properties:
services:
description: Services is a list of services to be exported and the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

load _helpers

@test "partitionExports/CustomerResourceDefinition: disabled by default" {
@test "exportedServices/CustomerResourceDefinition: disabled by default" {
cd `chart_dir`
assert_empty helm template \
-s templates/crd-partitionexports.yaml \
-s templates/crd-exportedservices.yaml \
.
}

@test "partitionExports/CustomerResourceDefinition: enabled with controller.enabled=true" {
@test "exportedServices/CustomerResourceDefinition: enabled with controller.enabled=true" {
cd `chart_dir`
local actual=$(helm template \
-s templates/crd-partitionexports.yaml \
-s templates/crd-exportedservices.yaml \
--set 'controller.enabled=true' \
. | tee /dev/stderr |
# The generated CRDs have "---" at the top which results in two objects
Expand Down
2 changes: 1 addition & 1 deletion control-plane/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ resources:
- controller: true
domain: hashicorp.com
group: consul
kind: PartitionExport
kind: ExportedServices
path: github.com/hashicorp/consul-k8s/api/v1alpha1
version: v1alpha1
version: "3"
2 changes: 1 addition & 1 deletion control-plane/api/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const (
ServiceRouter string = "servicerouter"
ServiceSplitter string = "servicesplitter"
ServiceIntentions string = "serviceintentions"
PartitionExports string = "partitionexports"
ExportedServices string = "exportedservices"
IngressGateway string = "ingressgateway"
TerminatingGateway string = "terminatinggateway"

Expand Down
Loading

0 comments on commit 6408674

Please sign in to comment.