I’ve got a problem regarding deploying workloads via kubectl. So basically the way we do deploy our services is a combination of kubectl create -f deployment.yml and kubectl apply -f ... etc. This also works for our rancher 2 setup but alle those deployments are not appearing inside the rancher project UI. Instead they are listed at Project -> Namespaces -> Not in a project.
My question is: Do I need a special rancher/cattle annotation to add a deployment to a project or how do I do this?
Thats right! But I wanted to do this automatically say: kubectl create namespace test-namespace which will automatically be part of a given project or default if none is defined.
Maybe I did not express myself correctly.
I know how to create a namespace and or apply a yaml file. But when I am doing this remotely just by using kubectl create namespace foo the cluster DOES create a namespace but it is NOT actually bound to any rancher project. How do I bind a newly created namespace to a rancher project without accessing the UI. I thought I can bind it via any kind of annotation or something.
Got you! I created the namespace through the UI… it’s not so much deploying the workload in a namespace within a project then the problem, but creating namespaces within a project, through the CLI…
λ rancher.exe namespaces help
Operations on namespaces
Usage: rancher namespaces [OPTIONS] COMMAND [arg...]
Version: v2.0.1
Options:
--quiet, -q Only display IDs
--help, -h show help
Commands:
ls List namespaces
create Create a namespace
delete, [rm] Delete a namespace by name or ID
associate Associate a namespace with a project
help, [h] Shows a list of commands or help for one command
Run 'rancher namespaces COMMAND --help' for more information on a command.
Ahh thank you very much thats what I’ve been looking for! I thought it might work by an annotation in conjunction with a rancher auto discovery service or something like that. That would be nice.
Select the namespace and move it to the corresponding project. Probably the namespace was created by kubectl, that is why rancher does not have mapping of namespace->project. So, you should do it manually.