-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: Support Kubernetes v1.24. Fixes #8320 #9680
Changes from 15 commits
4e7375e
d0a20fa
e3c6a1b
925c40c
07e1914
0ecbf55
8c1ff73
6845549
fd24c1b
0e90d72
ecf1446
7f3ea32
a6fbd08
d04de07
771afed
b245bb0
e7d3c15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,7 +131,7 @@ jobs: | |
${{ runner.os }}-go- | ||
- name: Install and start K3S | ||
run: | | ||
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.21.2+k3s1 INSTALL_K3S_CHANNEL=stable INSTALL_K3S_EXEC=--docker K3S_KUBECONFIG_MODE=644 sh - | ||
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL=stable INSTALL_K3S_EXEC=--docker K3S_KUBECONFIG_MODE=644 sh - | ||
until kubectl --kubeconfig=/etc/rancher/k3s/k3s.yaml cluster-info ; do sleep 10s ; done | ||
cp /etc/rancher/k3s/k3s.yaml /home/runner/.kubeconfig | ||
echo "- name: fake_token_user" >> $KUBECONFIG | ||
|
@@ -155,14 +155,19 @@ jobs: | |
- run: make cli STATIC_FILES=false | ||
if: ${{matrix.test == 'test-api' || matrix.test == 'test-cli' || matrix.test == 'test-java-sdk' || matrix.test == 'test-python-sdk'}} | ||
- run: make start PROFILE=${{matrix.profile}} AUTH_MODE=client STATIC_FILES=false LOG_LEVEL=info API=${{matrix.test == 'test-api' || matrix.test == 'test-cli' || matrix.test == 'test-java-sdk' || matrix.test == 'test-python-sdk'}} UI=false AZURE=true > /tmp/argo.log 2>&1 & | ||
- run: make wait | ||
timeout-minutes: 4 | ||
- name: make wait | ||
# https://github.com/marketplace/actions/retry-step | ||
uses: nick-fields/[email protected] | ||
with: | ||
timeout_minutes: 4 | ||
max_attempts: 4 | ||
command: make wait | ||
- name: make ${{matrix.test}} | ||
# https://github.com/marketplace/actions/retry-step | ||
uses: nick-fields/[email protected] | ||
with: | ||
timeout_minutes: 20 | ||
max_attempts: 2 | ||
max_attempts: 4 | ||
command: make ${{matrix.test}} E2E_SUITE_TIMEOUT=20m STATIC_FILES=false AZURE=true | ||
- if: ${{ failure() }} | ||
run: | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,7 @@ v1.0 | |
v1.1 | ||
v1.2 | ||
v1.3 | ||
v1.24 | ||
v2 | ||
v2.10 | ||
v2.11 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Kubernetes Secrets | ||
|
||
As of Kubernetes v1.24, secrets are not automatically created for service accounts by default. [Find out how to create these yourself manually](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-service-account-api-token). | ||
|
||
Argo discovers your token by name, not annotation. They must be named `${serviceAccountName}.service-account-token`. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: default.service-account-token | ||
annotations: | ||
kubernetes.io/service-account.name: default | ||
type: kubernetes.io/service-account-token |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: template-executor-executor-plugin.service-account-token | ||
annotations: | ||
kubernetes.io/service-account.name: template-executor-executor-plugin | ||
type: kubernetes.io/service-account-token |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package secrets | ||
|
||
import ( | ||
"fmt" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func SecretName(serviceAccount *corev1.ServiceAccount) string { | ||
secretName := fmt.Sprintf("%s.service-account-token", serviceAccount.Name) | ||
if len(serviceAccount.Secrets) > 0 { | ||
secretName = serviceAccount.Secrets[0].Name | ||
} | ||
return secretName | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package secrets | ||
|
||
import ( | ||
"testing" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/stretchr/testify/assert" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestSecretName(t *testing.T) { | ||
sa := corev1.ServiceAccount{ | ||
ObjectMeta: metav1.ObjectMeta{Name: "sa-name"}, | ||
} | ||
assert.Equal(t, "sa-name.service-account-token", SecretName(&sa)) | ||
sa.Secrets = []corev1.ObjectReference{{Name: "existing-secret"}} | ||
assert.Equal(t, "existing-secret", SecretName(&sa)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ import ( | |
"sync" | ||
"time" | ||
|
||
"github.com/argoproj/argo-workflows/v3/util/secrets" | ||
|
||
"github.com/antonmedv/expr" | ||
"github.com/argoproj/pkg/humanize" | ||
argokubeerr "github.com/argoproj/pkg/kube/errors" | ||
|
@@ -3686,10 +3688,7 @@ func (woc *wfOperationCtx) getServiceAccountTokenName(ctx context.Context, name | |
if err != nil { | ||
return "", err | ||
} | ||
if len(account.Secrets) == 0 { | ||
return "", fmt.Errorf("service account %s/%s does not have any secrets", account.Namespace, account.Name) | ||
} | ||
return account.Secrets[0].Name, nil | ||
return secrets.SecretName(account), nil | ||
Comment on lines
-3690
to
+3691
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
EDIT: Nevermind, I just saw the implementation of SecretName and see that it is doing just that. |
||
} | ||
|
||
// setWfPodNamesAnnotation sets an annotation on a workflow with the pod naming | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could do better job explaining when users need to do this. When using Agent http template? Auth delegation in api server? Does this need to be mentioned in the SSO docs?