Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI Upgrade command #898

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
92a5a4f
test
kschoche Oct 21, 2021
8171ec5
test
kschoche Oct 21, 2021
3ba20ec
change something
kschoche Oct 21, 2021
3a0f5a3
clean this up
kschoche Oct 21, 2021
08daf43
remove interface and make bootstrap part of Create
kschoche Oct 21, 2021
a7ad878
clean up the framework a bit
kschoche Oct 26, 2021
d0de8e6
Apply suggestions from code review
kschoche Oct 27, 2021
da47c6e
review comments
kschoche Oct 27, 2021
400fda6
fix lint
kschoche Oct 27, 2021
3808657
Merge branch 'vault-acceptance-base' into consul-vault-base
kschoche Oct 28, 2021
01e9974
Merge branch 'main' into consul-vault-base
kschoche Nov 1, 2021
80102a5
Bootstrap gossip encryption with Vault (#811)
kschoche Nov 12, 2021
9c515aa
Add configuration for the vault Connect CA provider (#872)
ishustava Nov 24, 2021
84f1a8e
Support Vault server running with TLS (#874)
ishustava Dec 1, 2021
13282c4
Made an initial try at the consul-k8s upgrade command. Running into i…
sadjamz Nov 15, 2021
a9260b3
Upgrade commit
sadjamz Nov 17, 2021
412117d
First pass at upgrade was successful.
sadjamz Nov 18, 2021
855a94f
notes from sync with Saad on what's left
ndhanushkodi Nov 23, 2021
bcfd881
Made an initial try at the consul-k8s upgrade command. Running into i…
sadjamz Nov 15, 2021
c01583e
Upgrade commit
sadjamz Nov 17, 2021
cdcccfd
First pass at upgrade was successful.
sadjamz Nov 18, 2021
eb68ee8
notes from sync with Saad on what's left
ndhanushkodi Nov 23, 2021
ed58f2f
Some basic cleanup
Dec 1, 2021
2666ff6
Remove TestDebugger
Dec 1, 2021
1a9dcf9
Remove validateLabels (unused)
Dec 2, 2021
fd8255d
Add the namespace and install flags
Dec 2, 2021
bf38f5b
Add flag test and remove install option
Dec 3, 2021
b6a91c2
Move presets into a config package
Dec 3, 2021
1fd8497
Add Changelog
Dec 3, 2021
e0f3b71
Fail if partitions enabled with federation (#892)
Dec 6, 2021
d08821b
Change error handling when scraping metrics (#551)
lkysow Dec 6, 2021
738d80e
Server TLS bootstrapping (#881)
kschoche Dec 7, 2021
5078a48
Merge branch 'main' into consul-vault-base
kschoche Dec 7, 2021
8107dd1
mod tidy
kschoche Dec 7, 2021
09f0ac2
fix merge error
kschoche Dec 7, 2021
ea85df1
add changelog entries
kschoche Dec 7, 2021
2e9da0d
cli: allow enterprise images to be named without the string "-ent" (#…
ndhanushkodi Dec 7, 2021
c1df868
Add support for ingressClassName
NiklasWagner Oct 12, 2021
adc71ca
Apply suggestions from code review
kschoche Dec 7, 2021
6c510cc
Reset ui ingress default to false
Dec 7, 2021
737b970
Test ingress UI with different Kube versions
Dec 7, 2021
5df0004
Apply suggestions from code review
kschoche Dec 7, 2021
5a728f4
Add Changelog entry for ingressClassName
Dec 7, 2021
053af17
Merge pull request #904 from hashicorp/consul-vault-base
kschoche Dec 7, 2021
aea9efe
Add docs about choosing storage class (#907)
lkysow Dec 7, 2021
6408674
Rename to exported services (#902)
Dec 8, 2021
ce6b2a7
Add support for tproxy for partitions test (#901)
Dec 8, 2021
e1badb2
Merge pull request #909 from hashicorp/ingress-class-name
Dec 8, 2021
b7f9331
Update service resolver/splitter/router with partitions (#908)
Dec 8, 2021
71a6bb6
Retry testing the merged metrics (#914)
lkysow Dec 8, 2021
4143aff
1.11.0 rc (#913)
Dec 8, 2021
f84fef0
Update version to 0.38.0 (#915)
Dec 8, 2021
dd1e1b0
Release v0.38.0
hc-github-team-consul-ecosystem Dec 8, 2021
aee48f0
Putting source back into Dev Mode
hc-github-team-consul-ecosystem Dec 8, 2021
45d065b
add psp support when its configured
kschoche Dec 9, 2021
363186b
go mod tidy vs 1.17
kschoche Dec 9, 2021
65a91a9
anony token
Dec 9, 2021
9c4bee4
Revert erronous commit
Dec 9, 2021
c4cafff
Merge pull request #917 from hashicorp/enable-psp-vault
kschoche Dec 10, 2021
e355006
Made an initial try at the consul-k8s upgrade command. Running into i…
sadjamz Nov 15, 2021
d575746
Upgrade commit
sadjamz Nov 17, 2021
8215641
First pass at upgrade was successful.
sadjamz Nov 18, 2021
8ce3d2c
notes from sync with Saad on what's left
ndhanushkodi Nov 23, 2021
ca14653
Made an initial try at the consul-k8s upgrade command. Running into i…
sadjamz Nov 15, 2021
3da54cd
Upgrade commit
sadjamz Nov 17, 2021
2920d3e
First pass at upgrade was successful.
sadjamz Nov 18, 2021
355be3c
notes from sync with Saad on what's left
ndhanushkodi Nov 23, 2021
56db257
Some basic cleanup
Dec 1, 2021
f5ccd78
Remove TestDebugger
Dec 1, 2021
61cf678
Remove validateLabels (unused)
Dec 2, 2021
7a409af
Add the namespace and install flags
Dec 2, 2021
1c660a6
Add flag test and remove install option
Dec 3, 2021
a0e2426
Move presets into a config package
Dec 3, 2021
ca1c6c0
Add Changelog
Dec 3, 2021
b770d3c
Merge branch 'cli-upgrade' of https://github.com/hashicorp/consul-k8s…
Dec 13, 2021
c05744f
Mark CHANGELOG update as BETA
Dec 13, 2021
e09f2e2
Remove namespace from upgrade
Dec 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ executors:
- image: docker.mirror.hashicorp.services/circleci/golang:1.17
environment:
TEST_RESULTS: /tmp/test-results # path to where test results are saved
CONSUL_VERSION: 1.11.0-beta3 # Consul's OSS version to use in tests
CONSUL_ENT_VERSION: 1.11.0+ent-beta3 # Consul's enterprise version to use in tests
CONSUL_VERSION: 1.11.0-rc # Consul's OSS version to use in tests
CONSUL_ENT_VERSION: 1.11.0+ent-rc # Consul's enterprise version to use in tests

control-plane-path : &control-plane-path control-plane
cli-path : &cli-path cli
Expand Down
44 changes: 38 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
## UNRELEASED

## 0.38.0 (December 08, 2021)

BREAKING CHANGES:
* Update minimum go version for project to 1.17 [[GH-878](https://github.com/hashicorp/consul-k8s/pull/878)]
* Control Plane
* Update minimum go version for project to 1.17 [[GH-878](https://github.com/hashicorp/consul-k8s/pull/878)]
* 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)]

FEATURES:
* Vault as a Secrets Backend: Add support for Vault as a secrets backend for Gossip Encryption, Server TLS certs and Service Mesh TLS certificates,
removing the existing usage of Kubernetes Secrets for the respective secrets. [[GH-904](https://github.com/hashicorp/consul-k8s/pull/904/)]

See the [Consul Kubernetes and Vault documentation](https://www.consul.io/docs/k8s/installation/vault)
for full install instructions.

Requirements:
* Consul 1.11+
* Vault 1.19+ and Vault-K8s 0.14+ must be installed with the Vault Agent Injector enabled (`injector.enabled=true`)
into the Kubernetes cluster that Consul is installed into.
* `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)]

FEATURES:
* CLI
* **BETA** Add `upgrade` command to modify Consul installation on Kubernetes. [[GH-898](https://github.com/hashicorp/consul-k8s/pull/898)]

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)]
* 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)]
* 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)]
* Add support for labeling a Kubernetes service with `consul.hashicorp.com/service-ignore` to prevent services from being registered in Consul. [[GH-858](https://github.com/hashicorp/consul-k8s/pull/858)]
* Helm Chart
* Fail an installation/upgrade if WAN federation and Admin Partitions are both enabled. [[GH-892](https://github.com/hashicorp/consul-k8s/issues/892)]
* Add support for setting `ingressClassName` for UI. [[GH-909](https://github.com/hashicorp/consul-k8s/pull/909)]
* Add partition support to Service Resolver, Service Router and Service Splitter CRDs. [[GH-908](https://github.com/hashicorp/consul-k8s/issues/908)]

BUG FIXES:
* Control Plane:
* Add a workaround to check that the ACL token is replicated to other Consul servers. [[GH-862](https://github.com/hashicorp/consul-k8s/issues/862)]

BUG FIXES:
* Add a workaround to check that the ACL token is replicated to other Consul servers. [[GH-862](https://github.com/hashicorp/consul-k8s/issues/862)]
* Return 500 on prometheus response if unable to get metrics from Envoy. [[GH-551](https://github.com/hashicorp/consul-k8s/pull/551)]
* Don't include body of failed service metrics calls in merged metrics response. [[GH-551](https://github.com/hashicorp/consul-k8s/pull/551)]
* Helm Chart
* Admin Partitions **(Consul Enterprise only)**: Do not mount Consul CA certs to partition-init job if `externalServers.useSystemRoots` is `true`. [[GH-885](https://github.com/hashicorp/consul-k8s/pull/885)]

Expand Down
46 changes: 1 addition & 45 deletions acceptance/framework/consul/consul_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package consul

import (
"context"
"encoding/json"
"fmt"
"strings"
"testing"
Expand Down Expand Up @@ -115,7 +114,7 @@ func (h *HelmCluster) Create(t *testing.T) {
})

// Fail if there are any existing installations of the Helm chart.
h.checkForPriorInstallations(t)
helpers.CheckForPriorInstallations(t, h.kubernetesClient, h.helmOptions, "consul-helm", "chart=consul-helm")

helm.Install(t, h.helmOptions, config.HelmChartPath, h.releaseName)

Expand Down Expand Up @@ -281,49 +280,6 @@ func (h *HelmCluster) SetupConsulClient(t *testing.T, secure bool) *api.Client {
return consulClient
}

// checkForPriorInstallations checks if there is an existing Helm release
// for this Helm chart already installed. If there is, it fails the tests.
func (h *HelmCluster) checkForPriorInstallations(t *testing.T) {
t.Helper()

var helmListOutput string
// Check if there's an existing cluster and fail if there is one.
// We may need to retry since this is the first command run once the Kube
// cluster is created and sometimes the API server returns errors.
retry.RunWith(&retry.Counter{Wait: 1 * time.Second, Count: 3}, t, func(r *retry.R) {
var err error
// NOTE: It's okay to pass in `t` to RunHelmCommandAndGetOutputE despite being in a retry
// because we're using RunHelmCommandAndGetOutputE (not RunHelmCommandAndGetOutput) so the `t` won't
// get used to fail the test, just for logging.
helmListOutput, err = helm.RunHelmCommandAndGetOutputE(t, h.helmOptions, "list", "--output", "json")
require.NoError(r, err)
})

var installedReleases []map[string]string

err := json.Unmarshal([]byte(helmListOutput), &installedReleases)
require.NoError(t, err, "unmarshalling %q", helmListOutput)

for _, r := range installedReleases {
require.NotContains(t, r["chart"], "consul", fmt.Sprintf("detected an existing installation of Consul %s, release name: %s", r["chart"], r["name"]))
}

// Wait for all pods in the "default" namespace to exit. A previous
// release may not be listed by Helm but its pods may still be terminating.
retry.RunWith(&retry.Counter{Wait: 1 * time.Second, Count: 60}, t, func(r *retry.R) {
consulPods, err := h.kubernetesClient.CoreV1().Pods(h.helmOptions.KubectlOptions.Namespace).List(context.Background(), metav1.ListOptions{})
require.NoError(r, err)
if len(consulPods.Items) > 0 {
var podNames []string
for _, p := range consulPods.Items {
podNames = append(podNames, p.Name)
}
r.Errorf("pods from previous installation still running: %s", strings.Join(podNames, ", "))
}
})

}

// configurePodSecurityPolicies creates a simple pod security policy, a cluster role to allow access to the PSP,
// and a role binding that binds the default service account in the helm installation namespace to the cluster role.
// We bind the default service account for tests that are spinning up pods without a service account set so that
Expand Down
50 changes: 48 additions & 2 deletions acceptance/framework/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package helpers

import (
"context"
"encoding/json"
"fmt"
"os"
"os/signal"
Expand All @@ -10,6 +11,8 @@ import (
"testing"
"time"

"github.com/gruntwork-io/terratest/modules/helm"

terratestk8s "github.com/gruntwork-io/terratest/modules/k8s"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/hashicorp/consul-k8s/acceptance/framework/logger"
Expand All @@ -25,14 +28,56 @@ func RandomName() string {
return fmt.Sprintf("test-%s", strings.ToLower(random.UniqueId()))
}

// CheckForPriorInstallations checks if there is an existing Helm release
// for this Helm chart already installed. If there is, it fails the tests.
func CheckForPriorInstallations(t *testing.T, client kubernetes.Interface, options *helm.Options, chartName, labelSelector string) {
t.Helper()

var helmListOutput string
// Check if there's an existing cluster and fail if there is one.
// We may need to retry since this is the first command run once the Kube
// cluster is created and sometimes the API server returns errors.
retry.RunWith(&retry.Counter{Wait: 1 * time.Second, Count: 3}, t, func(r *retry.R) {
var err error
// NOTE: It's okay to pass in `t` to RunHelmCommandAndGetOutputE despite being in a retry
// because we're using RunHelmCommandAndGetOutputE (not RunHelmCommandAndGetOutput) so the `t` won't
// get used to fail the test, just for logging.
helmListOutput, err = helm.RunHelmCommandAndGetOutputE(t, options, "list", "--output", "json")
require.NoError(r, err)
})

var installedReleases []map[string]string

err := json.Unmarshal([]byte(helmListOutput), &installedReleases)
require.NoError(t, err, "unmarshalling %q", helmListOutput)

for _, r := range installedReleases {
require.NotContains(t, r["chart"], chartName, fmt.Sprintf("detected an existing installation of %s %s, release name: %s", chartName, r["chart"], r["name"]))
}

// Wait for all pods in the "default" namespace to exit. A previous
// release may not be listed by Helm but its pods may still be terminating.
retry.RunWith(&retry.Counter{Wait: 1 * time.Second, Count: 60}, t, func(r *retry.R) {
pods, err := client.CoreV1().Pods(options.KubectlOptions.Namespace).List(context.Background(), metav1.ListOptions{LabelSelector: labelSelector})
require.NoError(r, err)
if len(pods.Items) > 0 {
var podNames []string
for _, p := range pods.Items {
podNames = append(podNames, p.Name)
}
r.Errorf("pods from previous installation still running: %s", strings.Join(podNames, ", "))
}
})
}

// WaitForAllPodsToBeReady waits until all pods with the provided podLabelSelector
// are in the ready status. It checks every 5 seconds for a total of 20 tries.
// If there is at least one container in a pod that isn't ready after that,
// it fails the test.
func WaitForAllPodsToBeReady(t *testing.T, client kubernetes.Interface, namespace, podLabelSelector string) {
t.Helper()

logger.Log(t, "Waiting for pods to be ready.")
logger.Logf(t, "Waiting for pods with label %q to be ready.", podLabelSelector)

// Wait up to 10m.
// On Azure, volume provisioning can sometimes take close to 5 min,
Expand All @@ -41,6 +86,7 @@ func WaitForAllPodsToBeReady(t *testing.T, client kubernetes.Interface, namespac
retry.RunWith(counter, t, func(r *retry.R) {
pods, err := client.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{LabelSelector: podLabelSelector})
require.NoError(r, err)
require.NotEmpty(r, pods.Items)

var notReadyPods []string
for _, pod := range pods.Items {
Expand All @@ -55,7 +101,7 @@ func WaitForAllPodsToBeReady(t *testing.T, client kubernetes.Interface, namespac
logger.Log(t, "Finished waiting for pods to be ready.")
}

// Sets up a goroutine that will wait for interrupt signals
// SetupInterruptHandler sets up a goroutine that will wait for interrupt signals
// and call cleanup function when it catches it.
func SetupInterruptHandler(cleanup func()) {
c := make(chan os.Signal, 1)
Expand Down
1 change: 1 addition & 0 deletions acceptance/framework/k8s/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func CheckStaticServerConnectionFailing(t *testing.T, options *k8s.KubectlOption
CheckStaticServerConnection(t, options, false, []string{
"curl: (52) Empty reply from server",
"curl: (7) Failed to connect",
"curl: (56) Recv failure: Connection reset by peer",
}, curlArgs...)
}

Expand Down
Loading