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

Loading manifests without namespace specified fails #151

Closed
dpen2000 opened this issue Mar 4, 2019 · 4 comments
Closed

Loading manifests without namespace specified fails #151

dpen2000 opened this issue Mar 4, 2019 · 4 comments
Labels
kind/bug Something isn't working
Milestone

Comments

@dpen2000
Copy link
Contributor

dpen2000 commented Mar 4, 2019

Describe the bug
K3s fails to load manifests from /var/lib/rancher/k3s/server/manifests if they don't specify a namespace.

To Reproduce

  1. Run k3s server in one terminal
  2. Run nano /var/lib/rancher/k3s/server/manifests/deployment.yaml in another terminal
  3. Paste ( from https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/ ):
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
  1. Save
  2. k3s logs in first terminal show error:
ERRO[2019-03-04T23:49:11.027423617Z] failed to process config: failed to process /var/lib/rancher/k3s/server/manifests/deployment.yaml: failed to create nginx-deployment apps/v1, Kind=Deployment for deployment: an empty namespace may not be set during creation

Expected behavior
K3s should assume default namespace and create deployment as per kubectl apply

@dpen2000
Copy link
Contributor Author

dpen2000 commented Mar 5, 2019

@ibuildthecloud I've got k3s building myself now so happy to try to send a PR for this one.

@ibuildthecloud
Copy link
Contributor

@dpen2000 I went ahead and tried to fix this while I was fixing another bug, but it's not heavily tested. Do you want to give v0.2.0-rc6 a try and see if its working now? It should assign the namespace to "default" for namespaced resources where the namespace is "".

@dpen2000
Copy link
Contributor Author

dpen2000 commented Mar 7, 2019

@ibuildthecloud The example above works. As for helm charts, I tried:

apiVersion: k3s.cattle.io/v1
kind: HelmChart
metadata:
  name: redis
spec:
  chart: stable/redis

which doesn't work for me. I don't get any error output about it either. This doesn't either:

apiVersion: k3s.cattle.io/v1
kind: HelmChart
metadata:
  name: redis
  namespace: default
spec:
  chart: stable/redis

Only specifiying kube-system seems to work:

apiVersion: k3s.cattle.io/v1
kind: HelmChart
metadata:
  name: redis
  namespace: kube-system
spec:
  chart: stable/redis

Editing this chart to say default results in it creating job.batch/helm-delete-redis to delete redis from cluster.

@erikwilson
Copy link
Contributor

Also verified that example nginx deployment works, created a new issue for Helm deployments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants