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

Module type: kubernetes with rbac settings produce an error #1191

Closed
kvokka opened this issue Sep 17, 2019 · 2 comments · Fixed by #1197
Closed

Module type: kubernetes with rbac settings produce an error #1191

kvokka opened this issue Sep 17, 2019 · 2 comments · Fixed by #1197
Assignees
Labels
bug priority:medium Medium priority issue or feature

Comments

@kvokka
Copy link

kvokka commented Sep 17, 2019

Bug

Current Behavior

Given a manifest with custom role && role binding.

# support/rbac/garden.yaml

kind: Module
type: kubernetes
name: poker-core-rbac
description: Rbac extension for poker-core
manifests:
  - apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: with-endpoints
      namespace: default
    rules:
      - apiGroups:
          - ""
        resources:
          - endpoints
        verbs:
          - get
          - list
  - apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: endpoints-access-by-default
      namespace: default
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: with-endpoints
    subjects:
      - kind: ServiceAccount
        name: default
        namespace: default

or

# support/rbac/garden.yaml

kind: Module
type: kubernetes
name: poker-core-rbac
description: Rbac extension for poker-core
files: [endpoints.yaml]

garden scan shows no errors, but with garden dev constantly getting:

$garden dev
✔ providers                 → Getting status... → Done
✔ postgres                  → Building version v-8d9e4b5e75... → Done (took 2 sec)
✔ pubsub-emulator-image     → Getting build status for v-19730a28c8... → Done (took 0.7 sec)
✔ pubsub-emulator           → Getting build status for v-3495fb91dd... → Done (took 0.6 sec)
✔ redis                     → Building version v-87278bbcb5... → Done (took 1.8 sec)
✔ pubsub-emulator           → Deploying version v-3495fb91dd... → Done (took 3.9 sec)
   ℹ pubsub-emulator           → Service deployed
   → Forward: http://localhost:62833 → pubsub-emulator:8538 (pubsub-emulator)
✔ poker-core-rbac           → Building version v-9b71094f61... → Done (took 0.2 sec)
✖ poker-core-rbac           → Deploying version v-9b71094f61...

Failed deploying service 'poker-core-rbac' (from module 'poker-core-rbac'). Here is the output:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Command failed with exit code 1 (EPERM): /Users/mike/.garden/tools/kubectl/52606cbad4c7babc/kubectl --context=
minikube --namespace=rp --context=minikube --namespace=rp apply --prune --selector garden.io/service=poker-cor
e-rbac --output=json -f -
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The same behavior with both formats.

Unfortunately, this link does not cover the case for MacOs.

Expected behavior

No error

Your environment

OS
MacOs 10.14.6

garden version
0.10.9
kubectl version
1.15.2
docker version
2.1.0.2

@kvokka
Copy link
Author

kvokka commented Sep 17, 2019

Later I found, in error.log the answer to my question.

stderr: >-
  the namespace from the provided object "default" does not match the namespace
  "rp". You must pass '--namespace=default' to perform this operation.

This error message is great and helps a lot, while the default message is more misleading than helpful. Maybe at least add some notice about error.log for others? It should save time.

@edvald
Copy link
Collaborator

edvald commented Sep 17, 2019

Thanks for the report @kvokka !

I see two things to fix:

  1. Make sure we print the stderr when kubectl commands fail.
  2. We should not pass the --namespace parameter in the command in question, but rather apply the namespace attribute when none is specified.

We'll try and get those sorted asap.

@edvald edvald added bug priority:medium Medium priority issue or feature labels Sep 17, 2019
edvald added a commit that referenced this issue Sep 17, 2019
Previously we set the --namespace flag when applying the specified
resources. We now instead ensure the namespace property is set on every
relevant resource.

Fixes #1191
@edvald edvald self-assigned this Sep 17, 2019
edvald added a commit that referenced this issue Sep 18, 2019
Previously we set the --namespace flag when applying the specified
resources. We now instead ensure the namespace property is set on every
relevant resource.

Fixes #1191
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug priority:medium Medium priority issue or feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants