The agent must assume `default` if no namespace is given
Problem
Assume the following manifest.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: config-without-ns
data:
fooconfig.properties: |
foo=bar
If we use kubectl apply -f manifest.yaml
it will provision this ConfigMap
without a problem.
The agent fails to provision this resource with the message:
an empty namespace may not be set when a resource name is provided
Logs
time="2020-09-29T19:41:29Z" level=info msg=syncing skipHooks=false started=false │
│ time="2020-09-29T19:41:29Z" level=info msg=tasks tasks="[Sync/0 resource /Namespace:/game-ns obj->nil (,,), Sync/0 resource /Namespace:/gitlab obj->nil (,,), Sync/0 resource /ConfigMap:/config-without │
│ -ns nil->obj (,,), Sync/0 resource /ConfigMap:game-ns/game-config obj->nil (,,), Sync/0 resource /ServiceAccount:gitlab/gitlab-runner-gitlab-runner obj->nil (,,)]" │
│ time="2020-09-29T19:41:29Z" level=info msg="Applying resource ConfigMap/config-without-ns in cluster: https://10.20.0.1:443, namespace: " │
│ time="2020-09-29T19:41:29Z" level=info msg="apply failed" dryRun=true message="error when retrieving current configuration of:\nResource: \"/v1, Resource=configmaps\", GroupVersionKind: \"/v1, Kind=Co │
│ nfigMap\"\nName: \"config-without-ns\", Namespace: \"\"\nfrom server for: \"/dev/shm/525553235\": an empty namespace may not be set when a resource name is provided" task="Sync/0 resource /ConfigMap:/ │
│ config-without-ns nil->obj (,,)" │
│ time="2020-09-29T19:41:29Z" level=info msg="adding resource result, status: 'SyncFailed', phase: 'Failed', message: 'error when retrieving current configuration of:\nResource: \"/v1, Resource=configma │
│ ps\", GroupVersionKind: \"/v1, Kind=ConfigMap\"\nName: \"config-without-ns\", Namespace: \"\"\nfrom server for: \"/dev/shm/525553235\": an empty namespace may not be set when a resource name is provid │
│ ed'" kind=ConfigMap name=config-without-ns namespace= phase=Sync │
│ time="2020-09-29T19:41:29Z" level=info msg="Updating operation state. phase: -> Failed, message: '' -> 'one or more objects failed to apply (dry run)'" │
│ time="2020-09-29T19:41:29Z" level=info msg=Synced project_id=root/agent-runner-config resource_key=/ConfigMap//config-without-ns sync_result="error when retrieving current configuration of:\nResource: │
│ \"/v1, Resource=configmaps\", GroupVersionKind: \"/v1, Kind=ConfigMap\"\nName: \"config-without-ns\", Namespace: \"\"\nfrom server for: \"/dev/shm/525553235\": an empty namespace may not be set when │
│ a resource name is provided"
Proposal
Follow the same pattern that other client tools assume and use the default
namespace whenever metadata.namespace
is not indicated.
/cc @ash2k