This message was deleted.
# general
a
This message was deleted.
a
I managed to get Rancher to spin up instances in OpenStack, but the "cacert" fields and the "userdataFile" fields of the driver appear to only honor a single line for entry. Turns out that I do not need the "cacert" field for my environment, but I do need to inject user data in a cloud-init fashion.
These seem related to: https://github.com/rancher/rancher/issues/38321 <-- in my case, I only see the password field and not the additional fields when filling out the cloud credential https://github.com/rancher/rancher/issues/37754 <-- same issue. https://github.com/rancher/rancher/issues/20788 <-- older, but appears to imply that userdata is now multiline, but the v2.8.x seems to imply that this is still single line
Running Rancher Manager v2.8.2. Anyone found a way to coax these two fields ("cacert" and "userDataFile") into accepting more than a single line?
c
Hey Zane I'm also working with rancher on openstack. I'm using the terraform provider tho. It may help convert your scripts/cacert into 1 line. I do this with my private key and things work well
I'm also curious how far you've made it with openstack, I'm just starting out with rancher on openstack. I've got instance creation down with node drivers but I can't seem to get the cloud-provider working, bleh. Do you use openstack as your cloud provider or just for a node driver?
a
Thanks @creamy-crayon-86622. I did manage to get Rancher to deploy a cluster to OpenStack. I am using the node driver included with Rancher Manager. We are pretty new to OpenStack, so this was a bit of a learning curve. Some updates on deploying resources to OpenStack: cacert - I managed to work around the cacert by checking an ignore cert option in the OpenStack node driver settings in the Rancher UI. Not ideal, but this is a lab environment with Rancher manager and OpenStack behind the same security perimeter. cloud config - After playing with OpenStack and manually deploying an Ubuntu cloud image with some cloud-init text, I did notice that OpenStack converted my cloud-init into a Base-64 encoded single line in the VM definition. Based on that, I converted the cloud-init text that I wanted Rancher to deploy to Base-64 and added it to my Rancher OpenStack deployment configuration. However, it errored out with an invalid cloud config error message. In the end, I chose to go without the cloud config file, as I was only using it to set SSH passwords for troubleshooting. I can use the Rancher UI to open an SSH session, and there weren't any other packages that I needed to add to the cloud image. I wish the node driver had better documentation... terraform - I did use Terraform to deploy a test domain, project, network, router, and VM. This was mostly getting familiar with the provider for the purpose of deploying VMs, but it had less "friction" than using the OpenStack node driver, so I may use Terraform for the initial cluster VM deployment in the future and import the cluster into Rancher. At the end of the day, we coaxed it into working. But the documentation could be better.
c
Yeah I totally hear ya. I haven't had any luck getting the cloud config working for openstack. The node driver works without the cloud config being set tho. You just have to put in your openstack env vars. I'm using the terraform rancher providers rancher2_machine_config_v2 resource to build out the driver. But I wasn't able to get the outputs of all the IP addresses of all the vms so it didn't seem helpful. It allows me to scale vms tho which is cool. I'm also going the terraform route of building vms and then just adding them to the cluster. Seems to be the easiest and quickest solution so far. And like you mentioned, the docs aren't that great bleh I'm curious tho, are you using openstacks native load balancing solution Octavia? That's the next piece I'm working with now. I'm just using a wildcard DNS record pointing to my k8s workers at the moment which isn't great but it gets me by. I don't want to deploy custom loadbalancers... Yet lol
πŸ‘ 1
a
Not using Octavia (yet). I tend to use ingress controllers (e.g. NGINX or Traefik) deployed inside the clusters and couple them with the MetalLB load balancer. As long as I can get an L2/VLAN IP for MetalLB, then I can expose the apps via ingress controller (front-ended with the MetalLB IP). Plus, using MetalLB keeps things consistent across Rancher-deployed clusters regardless of whether I'm deploying to OpenStack, Harvester, or VMWare as the driver. But that's on-prem. For cloud providers, using the cloud-provided ingress/load balancers makes more sense.
e
Hi, I started setting up rke2 cluster within OpenStack. Did you manage to get userdataFile to work? I just need to add nfs-common on all my nodes that are deployed via the rancher ui but for some reason the added config never runs.
#cloud-config package_update: true package_upgrade: true packages: ['nfs-common']
c
Hey Marcel you may have to base64 encode that script. I haven't used user data for k8s tho but openstack instances appear to like that
e
When I base64 encode it the node provisioning fails with
existing userdata file does not begin with '#!' or '#cloud-config'
a
Looking at the cloud provider docs (https://github.com/kubernetes/cloud-provider-openstack/blob/master/docs/openstack-[…]-controller-manager/using-openstack-cloud-controller-manager.md), while it does not have a reference to a
userDataFile
field, some of the other fields that are referred to as files (e.g.
clouds-file
,
cert-file
, and
key-file
) are described as paths to files and not actually file content. I wonder if the
cacert
and
userDataFile
fields are actually supposed to be file paths/URIs/URLs.
e
considering the errors that I am getting, when not providing proper content, that doesn't seem to be the case.
πŸ‘ 1
a
Looking at https://cloudinit.readthedocs.io/en/latest/reference/datasources/openstack.html, I decided to replace all carriage returns in my cloud config file with "\n". This gave me a single line configuration that Rancher did not complain about. However, looking at the created instance (VM) on OpenStack, the decoded contents of the User Data seem to indicate that Rancher uses this to inject its scripts. There is no indication that the
userDataFile
contents that I configure (just SSH password settings and quemu guest agent) are being merged.
e
I have opend a bug report, because that seems to be the case: https://github.com/rancher/rancher/issues/46311 OpenStacks accepts cloud config content like
#!/usr/bin/env -S bash -c "echo Start node >> /home/ubuntu/start.log
therefore it should also work when setting the same in rancher, since it is literally a single line. I want to check what happens if I set Cloud Provider to external within the Cluster Configuration menu, instead of using rke default. Maybe cloud config can be set there with multiline content.
πŸ™Œ 1
At least I found out where the configuration is saved: In the Namespace
fleet-default
->
rke-machine-config.cattle.io.openstackconfigs
With this maybe things can be test out direclty
one thing that seems interesting is that depending on the content len gth insertet into the userDataFile (in the cluster manager) gives different results when checking the
rke-machine-config.cattle.io.openstackconfigs
file: Single line:
Copy code
userDataFile: '#cloud-config runcmd:["echo Start node >> /home/ubuntu/start.log"]'
Multiline:
Copy code
userDataFile: >-
  #cloud-config package_update: true package_upgrade: true packages:   -
  nfs-common cloud_config_modules:   - runcmd runcmd:   - echo "test" output:
  {all: '| tee -a /var/log/cloud-init-output.log'}
If you change that file so something like this, it will work:
Copy code
userDataFile: |
  #cloud-config
  runcmd:
    - echo Start node >> /home/ubuntu/start.log
πŸ™Œ 1
a
That's a good find! I'm hopeful that your bug report will result in the "userDataFile" field being expanded into a larger text block in the UI that allows users to copy/paste file contents. This would be similar to the UI behavior that we see in both the VMWare and Harvester cloud providers. However, I'm holding my breath on the UI change though, as the UI's for the node drivers and cloud providers generally reflect what is defined by the upstream. Still, what is placed into the "userDataFile" field should, at the very least, be merged with the contents that Rancher uses to run its agent deployment scripts, rather than completely overwritten/ignored by it. And, maybe update the Rancher docs to describe the format that the field expects to see.
e
Here someone made a good overview for how yaml handles newlines, spaces etc: https://stackoverflow.com/a/21699210 If that is correct I can guess what is going wrong. The single quoted string adds a new line with every space. The cloud-config has spaces which aren't supposed to be new lines, and therefore are not working. With
>-
maybe it is possible to work with
\n_
I did try out to set
CLuster Provider
to External and define
Cloud Provider Config
but I couldn't get it to work. Or do you maybe have another idea?
a
That's a good find! I have tried replacing my carriage returns with
\n
, but did not try using
|
Hopefully the bug report will get an official response on how this field should be formatted.
e
Since waiting for a reply/bugfix will probably take a while, I will create my own Cluster Template Helm Chart for OpenStack acording to this repo and comment: https://github.com/rancher/cluster-template-examples https://github.com/rancher/rancher/issues/40226#issuecomment-1399175288 With these I hopefully can get a solution that can be automated so that I don't have to edit the already deployed clusters manually
πŸ‘ 1
more or less got it to work (still have to do some bug fixes). Will go with this solution since it allows managing everything via fleet
πŸŽ‰ 1
Sould you be interessted, I made a public repo for deploying rke2 cluster templates in OpenStack: https://jugit.fz-juelich.de/iek-10/public/ict-platform/deployment/kubernetes/rke2-rancher-cluster-templates While not fully fleshed out (missing questions file, not 100% feature complete...), I think it is useable for production. It currently only supports OpenStack since I don't use other cluster provider, but they can be added as needed.
🦜 1
c
Hey do either one of you have any configuration examples I can look at? Still using rancher to try deploying my cluster. I'm deploying nodes via the openstack node driver, setting the cluster to the external cloud provider and passing in an additional manifest for the occm. But it appears coredns doesn't spin up and it causes my cattle agent to fail on DNS. If you guys have a run book or a set of steps you use that would be great.
e
That is more or less what I am currently running in a test environment. I only kept enabled what is required or potentially usefull (like cloud-init). Requirements: - A working rke2 cluster with rancher used as Management Cluster. - OpenStack node Driver enabled - Access to Openstack API via Application Credentials On Management Cluster: - Install the rke2 cluster template:
<https://jugit.fz-juelich.de/iek-10/public/ict-platform/deployment/kubernetes/rke2-rancher-cluster-templates>
- Configure OpenStack Access:
openstack-secrets.yaml
- Fill out the
values.yaml
, especially
x-openstackconfig
- Create a cluster using that file and the template - Login into the created Downstream Cluster (it will not show in rancher as running until you complete the next step) - Create
cloud-config
secret on Downstream Cluster - nano
cloud.conf
-
Copy code
[Global]
    auth-url="<https://example.com:5000/v3>"
    application-credential-id=""
    application-credential-secret=""
    region=""
    tls-insecure=false

    [LoadBalancer]
    manage-security-groups=false
    floating-network-id=""
    subnet-id=""
-
kubectl create secret -n kube-system generic cloud-config --from-file=./cloud.conf
- Wait until the cluster shows up as running in rancher Important notice:
Copy code
cluster.config:
  machineGlobalConfig:
    disable_cloud_controller: true
  machineSelectorConfig.kubelet_arg:
    - cloud-provider=external
These two options are crucial, without them OCCM will not work.
Outside of this I haven't done anything special, just basic rke2 and rancher deployment. You can also use user/password authentication for the OpenStack API, but I wouldn't recommend it.
Had to do some rearrangements in the repo, but now it is also available on Artifacthub: https://artifacthub.io/packages/helm/ict-platform/rke2-cluster-templates