-
Notifications
You must be signed in to change notification settings - Fork 839
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 missing permission for impersonation #1651
Open
varshab1210
wants to merge
5
commits into
argoproj-labs:master
Choose a base branch
from
varshab1210:add-impersonate-permission
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/01-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: argocd-test-impersonation | ||
--- | ||
apiVersion: argoproj.io/v1beta1 | ||
kind: ArgoCD | ||
metadata: | ||
name: argocd-test | ||
namespace: argocd-test-impersonation | ||
spec: | ||
extraConfig: | ||
application.sync.impersonation.enabled: "true" | ||
server: | ||
route: | ||
enabled: true | ||
status: | ||
phase: Available | ||
--- | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: argocd-cm | ||
namespace: argocd-test-impersonation | ||
data: | ||
application.sync.impersonation.enabled: 'true' |
16 changes: 16 additions & 0 deletions
16
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/01-install.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: argocd-test-impersonation | ||
--- | ||
apiVersion: argoproj.io/v1beta1 | ||
kind: ArgoCD | ||
metadata: | ||
name: argocd-test | ||
namespace: argocd-test-impersonation | ||
spec: | ||
extraConfig: | ||
application.sync.impersonation.enabled: "true" | ||
server: | ||
route: | ||
enabled: true |
18 changes: 18 additions & 0 deletions
18
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/02-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: AppProject | ||
metadata: | ||
name: guestbook-proj | ||
namespace: argocd-test-impersonation | ||
spec: | ||
clusterResourceWhitelist: | ||
- group: '*' | ||
kind: '*' | ||
destinationServiceAccounts: | ||
- defaultServiceAccount: guestbook-deployer | ||
namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
destinations: | ||
- namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
sourceRepos: | ||
- 'https://github.com/argoproj/argocd-example-apps.git' |
18 changes: 18 additions & 0 deletions
18
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/02-create-appproject.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: AppProject | ||
metadata: | ||
name: guestbook-proj | ||
namespace: argocd-test-impersonation | ||
spec: | ||
clusterResourceWhitelist: | ||
- group: '*' | ||
kind: '*' | ||
destinationServiceAccounts: | ||
- defaultServiceAccount: guestbook-deployer | ||
namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
destinations: | ||
- namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
sourceRepos: | ||
- 'https://github.com/argoproj/argocd-example-apps.git' |
24 changes: 24 additions & 0 deletions
24
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/03-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: guestbook | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: guestbook-deployer | ||
namespace: guestbook | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: guestbook-deployer-rb | ||
namespace: guestbook | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: guestbook-deployer | ||
namespace: guestbook |
24 changes: 24 additions & 0 deletions
24
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/03-create-ns.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: guestbook | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: guestbook-deployer | ||
namespace: guestbook | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: guestbook-deployer-rb | ||
namespace: guestbook | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: guestbook-deployer | ||
namespace: guestbook |
24 changes: 24 additions & 0 deletions
24
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/04-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: guestbook | ||
namespace: argocd-test-impersonation | ||
spec: | ||
destination: | ||
namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
project: guestbook-proj | ||
source: | ||
directory: | ||
jsonnet: {} | ||
recurse: true | ||
path: guestbook | ||
repoURL: 'https://github.com/argoproj/argocd-example-apps' | ||
syncPolicy: | ||
automated: {} | ||
syncOptions: | ||
- ServerSideApply=true | ||
- CreateNamespace=true | ||
status: | ||
sync: | ||
status: Synced |
21 changes: 21 additions & 0 deletions
21
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/04-create-app.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: guestbook | ||
namespace: argocd-test-impersonation | ||
spec: | ||
destination: | ||
namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
project: guestbook-proj | ||
source: | ||
directory: | ||
jsonnet: {} | ||
recurse: true | ||
path: guestbook | ||
repoURL: 'https://github.com/argoproj/argocd-example-apps' | ||
syncPolicy: | ||
automated: {} | ||
syncOptions: | ||
- ServerSideApply=true | ||
- CreateNamespace=true |
44 changes: 44 additions & 0 deletions
44
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/05-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: AppProject | ||
metadata: | ||
name: guestbook-proj | ||
namespace: argocd-test-impersonation | ||
spec: | ||
clusterResourceWhitelist: | ||
- group: '*' | ||
kind: '*' | ||
destinationServiceAccounts: | ||
- defaultServiceAccount: guestbook-deployer | ||
namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
destinations: | ||
- namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
- namespace: guestbook-dev | ||
server: 'https://kubernetes.default.svc' | ||
sourceRepos: | ||
- 'https://github.com/argoproj/argocd-example-apps.git' | ||
--- | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: guestbook-dev | ||
namespace: argocd-test-impersonation | ||
spec: | ||
destination: | ||
namespace: guestbook-dev | ||
server: 'https://kubernetes.default.svc' | ||
project: guestbook-proj | ||
source: | ||
directory: | ||
jsonnet: {} | ||
recurse: true | ||
path: guestbook | ||
repoURL: 'https://github.com/argoproj/argocd-example-apps' | ||
syncPolicy: | ||
automated: {} | ||
syncOptions: | ||
- ServerSideApply=true | ||
status: | ||
health: | ||
status: Missing |
41 changes: 41 additions & 0 deletions
41
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/05-create-app.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: AppProject | ||
metadata: | ||
name: guestbook-proj | ||
namespace: argocd-test-impersonation | ||
spec: | ||
clusterResourceWhitelist: | ||
- group: '*' | ||
kind: '*' | ||
destinationServiceAccounts: | ||
- defaultServiceAccount: guestbook-deployer | ||
namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
destinations: | ||
- namespace: guestbook | ||
server: 'https://kubernetes.default.svc' | ||
- namespace: guestbook-dev | ||
server: 'https://kubernetes.default.svc' | ||
sourceRepos: | ||
- 'https://github.com/argoproj/argocd-example-apps.git' | ||
--- | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: guestbook-dev | ||
namespace: argocd-test-impersonation | ||
spec: | ||
destination: | ||
namespace: guestbook-dev | ||
server: 'https://kubernetes.default.svc' | ||
project: guestbook-proj | ||
source: | ||
directory: | ||
jsonnet: {} | ||
recurse: true | ||
path: guestbook | ||
repoURL: 'https://github.com/argoproj/argocd-example-apps' | ||
syncPolicy: | ||
automated: {} | ||
syncOptions: | ||
- ServerSideApply=true |
5 changes: 5 additions & 0 deletions
5
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/05-errors.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: guestbook-deployer | ||
namespace: guestbook-dev |
12 changes: 12 additions & 0 deletions
12
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/06-check-app.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
error_message=$(kubectl get app guestbook-dev -n argocd-test-impersonation -o jsonpath='{.status.operationState.message}') | ||
expected_error="failed to find a matching service account to impersonate\: no matching service account found for destination server" | ||
|
||
if echo "$error_message" | grep -q "$expected_error"; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |
13 changes: 13 additions & 0 deletions
13
tests/k8s/1-046_validate_impersonation_cluster_scoped_instance/99-delete.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
delete: | ||
- apiVersion: argoproj.io/v1beta1 | ||
kind: ArgoCD | ||
name: argocd-test | ||
- apiVersion: v1 | ||
kind: Namespace | ||
name: argocd-test-impersonation | ||
- apiVersion: v1 | ||
kind: Namespace | ||
name: guestbook |
26 changes: 26 additions & 0 deletions
26
tests/k8s/1-047_validate_impersonation_namespace_scoped_instance/01-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: argocd-test-ns-scoped | ||
--- | ||
apiVersion: argoproj.io/v1beta1 | ||
kind: ArgoCD | ||
metadata: | ||
name: argocd-test | ||
namespace: argocd-test-ns-scoped | ||
spec: | ||
extraConfig: | ||
application.sync.impersonation.enabled: "true" | ||
server: | ||
route: | ||
enabled: true | ||
status: | ||
phase: Available | ||
--- | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: argocd-cm | ||
namespace: argocd-test-ns-scoped | ||
data: | ||
application.sync.impersonation.enabled: 'true' |
16 changes: 16 additions & 0 deletions
16
tests/k8s/1-047_validate_impersonation_namespace_scoped_instance/01-install.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: argocd-test-ns-scoped | ||
--- | ||
apiVersion: argoproj.io/v1beta1 | ||
kind: ArgoCD | ||
metadata: | ||
name: argocd-test | ||
namespace: argocd-test-ns-scoped | ||
spec: | ||
extraConfig: | ||
application.sync.impersonation.enabled: "true" | ||
server: | ||
route: | ||
enabled: true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi @anandf, the current steps mentioned here do not work for a ns scoped instance. Could you please suggest the required modifications?
Even after adding the managed-by label, I see this error:
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.
Instead of
guestbook
namespace, can you try usingargocd-test-impersonation
as the destination ns ? For a namespace scopedArgoCD
instance, you can deploy manifests only in the same ns as the RBAC permits only that by default. Otherwise, you have to create a nsguestbook
and apply themanaged-by
label. You cannot test theCreateNamespace=true
sync policy in that case.