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

Update server-acl-init to always check for the deployed serviceAccountToken secret #1770

Merged
merged 56 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
fed11b7
test because I cant get tests to pass locally
kschoche Dec 5, 2022
90ad327
Remove controller from preset values file (#1755)
Ranjandas Dec 6, 2022
777fabe
Set consul api = v1.18.0, sdk = v0.13.0 and imageConsul = 1.14.2 (#1769)
curtbushko Dec 6, 2022
55f0912
CHANGELOG: Add 0.49.x series to release notes and 1.0.2 (#1772)
Dec 7, 2022
a9f794c
fix failing cli test (#1774)
kschoche Dec 7, 2022
6ea65a4
Add global.extraLabels values.yaml setting (#1771)
brucec5 Dec 7, 2022
7254fac
add usage of acceptance test suite to contributing guide for debuggin…
kschoche Dec 7, 2022
46c4a8f
Update CHANGELOG.md (#1779)
Dec 8, 2022
cdc7b0c
Create JIRA Github Sync (#1782)
Dec 13, 2022
732b804
JIRA sync: downgrade to tomhjp/gh-action-jira-create@v0.1.3 (#1784)
Dec 13, 2022
fd73492
JIRA: Use env when creating with custom fields (#1786)
Dec 13, 2022
8605ffd
Update jira.yaml (#1788)
Dec 13, 2022
dc58f69
missing quotes (#1790)
Dec 13, 2022
21a7be1
JIRA: Extra field for labels needs arrays (#1792)
Dec 13, 2022
b558ded
JIRA: Re-use previous structure from labels (#1794)
Dec 13, 2022
adb7fcf
JIRA: Add default work stream when syncing JIRA issues (#1796)
Dec 14, 2022
89bbe84
JIRA fix for search issue (#1801)
Dec 15, 2022
10b55e6
Add work stream to PR sync (#1803)
Dec 19, 2022
ad5040f
ignore partition/namespace on SourceIntention to match top-level conf…
kyhavlov Dec 16, 2022
6132470
Add changelog note
kyhavlov Dec 19, 2022
cd180fd
values.yaml - Fix helm docs for 1.0.x (#1810)
Dec 20, 2022
6915a96
feat: access logs update for proxy-defaults CRD
DanStough Dec 21, 2022
2e68a4f
move PR 1804 to unreleased (#1812)
Dec 22, 2022
5466c96
Create annotation to allows users to use proxy health check (#1824)
Jan 12, 2023
118ab10
Add envoyExtensions field to serviceDefaults and proxyDefaults CRDs (…
wilkermichael Jan 12, 2023
073d16f
updated tests to use 1.15-dev (#1831)
wilkermichael Jan 13, 2023
e55281e
Add health checks for services that are synced (#1821)
Jan 17, 2023
6d2bd27
[CONSUL-620] Refactor Package Import
joselo85 Jan 18, 2023
f6388b3
When configured, use the health check of the proxy (#1841)
Jan 19, 2023
371cd23
Bump Kubernetes versions for clouds for acceptance tests (#1852)
Jan 27, 2023
aae1022
Added first test for log command
jm96441n Jan 19, 2023
cdd38dd
Added initial flag parsing
jm96441n Jan 19, 2023
b1821b4
able to print and format output for getting current log levels for a
jm96441n Jan 19, 2023
3a26037
Add test for FetchLogLevel
jm96441n Jan 19, 2023
6811241
Add color to log level output to help differentiate levels
jm96441n Jan 20, 2023
68859ed
Added args for kubeconfig, kubecontext, and namespace, added comments,
jm96441n Jan 20, 2023
55c908b
Clean up, ran linter
jm96441n Jan 20, 2023
c11f494
Clean up variable usage in test
jm96441n Jan 20, 2023
cd7b8be
Removed unnecessary variable type
jm96441n Jan 20, 2023
a3ef037
PR feedback, DRY-ing up some error handling logic, cleaning up
jm96441n Jan 20, 2023
16dc54e
Move log name setting to the init function
jm96441n Jan 20, 2023
f5cd293
Update main to latest consul & consul-dataplane versions (late Jan 20…
curtbushko Feb 1, 2023
95e4b97
missing a line in the changelog (#1868)
curtbushko Feb 2, 2023
2d1fc49
Exclude openebs namespace from injection. (#1869)
lkysow Feb 2, 2023
99c68b3
feat: add peer to service-defaults overrides
DanStough Jan 26, 2023
146e3f9
chore: fix generation for peering CRDs
DanStough Jan 26, 2023
2d2a763
Refine server TLS Vault PKI role config (#1877)
jkirschner-hashicorp Feb 6, 2023
b01ebd4
Dockerfile: Remove gnupg from Consul k8s container (#1882)
Feb 7, 2023
4b7e240
Dockerfile: remove `gnupg` from dev image (#1885)
Feb 7, 2023
74849a0
NET-1750 Fixes ACL init command Consul Login Datacenter mixup (#1881)
missylbytes Feb 8, 2023
ff5b17e
Minor fixes to docs for acceptance tests (#1895)
analogue Feb 9, 2023
a595d01
Service to service troubleshooting (#1851)
curtbushko Feb 13, 2023
1e9e7a2
Added set command for log levels
jm96441n Jan 23, 2023
a8f6337
pinned consul test image to latest dev nightly (#1901)
wilkermichael Feb 14, 2023
38190ce
reset to original commit
Feb 14, 2023
1940e96
Add Changelog
thisisnotashwin Feb 14, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
IMPROVEMENTS:
* Helm:
* CNI: Add `connectInject.cni.namespace` stanza which allows the CNI plugin resources to be deployed in a namespace other than the namespace that Consul is installed. [[GH-1756](https://github.com/hashicorp/consul-k8s/pull/1756)]
* Control Plane:
* Server ACL Init always appends both, the secrets from the serviceAccount's secretRefs and the one created by the Helm chart, to support Openshift secret handling. [[GH-1770](https://github.com/hashicorp/consul-k8s/pull/1770)]

BUG FIXES:
* Helm:
Expand Down
17 changes: 7 additions & 10 deletions control-plane/subcommand/server-acl-init/connect_inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,13 @@ func (c *Command) createAuthMethodTmpl(authMethodName string, useNS bool) (api.A

var saSecret *apiv1.Secret
var secretNames []string
if len(authMethodServiceAccount.Secrets) == 0 {
// In Kube 1.24+ there is no automatically generated long term JWT token for a ServiceAccount.
// Furthermore, there is no reference to a Secret in the ServiceAccount. Instead we have deployed
// a Secret in Helm which references the ServiceAccount and contains a permanent JWT token.
secretNames = append(secretNames, c.withPrefix("auth-method"))
} else {
// ServiceAccounts always have a SecretRef in Kubernetes < 1.24. The Secret contains the JWT token.
for _, secretRef := range authMethodServiceAccount.Secrets {
secretNames = append(secretNames, secretRef.Name)
}
// In Kube 1.24+ there is no automatically generated long term JWT token for a ServiceAccount.
// Furthermore, there is no reference to a Secret in the ServiceAccount. Instead we have deployed
// a Secret in Helm which references the ServiceAccount and contains a permanent JWT token.
secretNames = append(secretNames, c.withPrefix("auth-method"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering about the order here for the Openshift case where it injects secrets into the ServiceAccount.
Are those supposed to hold the JWT token that we're supposed to use? if so I think we just need to re-order these four lines so that we attempt to read the Helm deployed Secret last?

// ServiceAccounts always have a SecretRef in Kubernetes < 1.24. The Secret contains the JWT token.
for _, secretRef := range authMethodServiceAccount.Secrets {
secretNames = append(secretNames, secretRef.Name)
}
// Because there could be multiple secrets attached to the service account,
// we need pick the first one of type corev1.SecretTypeServiceAccountToken.
Expand Down
18 changes: 16 additions & 2 deletions control-plane/subcommand/server-acl-init/connect_inject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ func TestCommand_createAuthMethodTmpl_SecretNotFound(t *testing.T) {
ctx: ctx,
}

// create the auth method secret since it is always deployed by helm chart.
authMethodSecretName := resourcePrefix + "-auth-method"
secret := &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: authMethodSecretName,
Labels: map[string]string{common.CLILabelKey: common.CLILabelValue},
},
Data: map[string][]byte{},
// Make it not a service-account-token so the test can pass through to checking the other secrets.
Type: v1.SecretTypeOpaque,
}
_, err := k8s.CoreV1().Secrets(ns).Create(ctx, secret, metav1.CreateOptions{})
require.NoError(t, err)

serviceAccountName := resourcePrefix + "-auth-method"
secretName := resourcePrefix + "-connect-injector"

Expand All @@ -53,15 +67,15 @@ func TestCommand_createAuthMethodTmpl_SecretNotFound(t *testing.T) {
}

// Create a secret of non service-account-token type (we're using the opaque type).
secret := &v1.Secret{
secret = &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Labels: map[string]string{common.CLILabelKey: common.CLILabelValue},
},
Data: map[string][]byte{},
Type: v1.SecretTypeOpaque,
}
_, err := k8s.CoreV1().Secrets(ns).Create(ctx, secret, metav1.CreateOptions{})
_, err = k8s.CoreV1().Secrets(ns).Create(ctx, secret, metav1.CreateOptions{})
require.NoError(t, err)

_, err = cmd.createAuthMethodTmpl("test", true)
Expand Down