-
Notifications
You must be signed in to change notification settings - Fork 137
Add proxmox cloud provider #1352
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a3955ff
Add proxmox provider
dermorz e04c020
Add proxmox example machinedeployment
dermorz a7c7674
Add unit test for userdata generation: ubuntu on proxmox
dermorz 70753cf
Cleanup
dermorz d8d8984
Improve proxmox docs
dermorz 74b2b5d
Catch up with recent versions
dermorz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Proxmox Virtual Environment | ||
|
|
||
| ## State of the implementation | ||
|
|
||
| Support for Proxmox as a provider in the machine-controller is currently just a technical demo. It | ||
| is possible to create MachineDeployments using manually created VM templates as demonstrated below. | ||
| In this example the VM template is using local storage, which is why this template can only be | ||
| cloned on the same node it is located at. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Authentication | ||
|
|
||
| For authentication the following data is needed: | ||
|
|
||
| - `user_id` is expected to be in the form `USER@REALM!TOKENID` | ||
| - `token` is just the UUID you get when initially creating the token | ||
|
|
||
| See also: | ||
| * https://pve.proxmox.com/wiki/User_Management#pveum_tokens | ||
| * https://pve.proxmox.com/wiki/Proxmox_VE_API#API_Tokens | ||
|
|
||
| #### User Privileges | ||
|
|
||
| For the provider to properly function the user needs an API token with the following privileges: | ||
|
|
||
| * `Datastore.AllocateSpace` | ||
| * `Pool.Allocate` | ||
| * `Pool.Audit` | ||
| * `VM.Allocate` | ||
| * `VM.Audit` | ||
| * `VM.Clone` | ||
| * `VM.Config.CDROM` | ||
| * `VM.Config.CPU` | ||
| * `VM.Config.Cloudinit` | ||
| * `VM.Config.Disk` | ||
| * `VM.Config.HWType` | ||
| * `VM.Config.Memory` | ||
| * `VM.Config.Network` | ||
| * `VM.Config.Options` | ||
| * `VM.Monitor` | ||
| * `Sys.Audit` | ||
| * `Sys.Console` | ||
|
|
||
| ### Cloud-init enabled VM Templates | ||
|
|
||
| Although it is possible to upload cloud-init images in Proxmox VE and create VM disks directly from | ||
| these images via CLI tools on the nodes directly, there is no API endpoint yet to provide this | ||
| functionality externally. That's why the `proxmox` provider assumes there are VM templates in place | ||
| to clone new machines from. | ||
|
|
||
| Proxmox recommends using either ready-to-use cloud-init images provided by many Linux distributions | ||
| (mostly designed for OpenStack) or to prepare the images yourself as you have full control over | ||
| what's in these images. | ||
|
|
||
| For VM templates to be available on all nodes, they need to be added to the `ha-manager`. | ||
|
|
||
| Example for creating a VM template: | ||
| ```bash | ||
| # Download the cloud-image. | ||
| wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img | ||
| INSTANCE_ID=9000 | ||
| # Create the VM that will be turned into the template. | ||
| qm create $INSTANCE_ID -name ubuntu-18.04-LTS | ||
| # Import the downloaded cloud-image as disk. | ||
| qm importdisk $INSTANCE_ID bionic-server-cloudimg-amd64.img local-lvm | ||
| # Set the imported Disk as SCSI drive. | ||
| qm set $INSTANCE_ID -scsihw virtio-scsi-pci -scsi0 local-lvm:vm-$INSTANCE_ID-disk-0 | ||
| # Create the cloud-init drive where the user-data is read from. | ||
| qm set $INSTANCE_ID -ide2 local-lvm:cloudinit | ||
| # Boot from the imported disk. | ||
| qm set $INSTANCE_ID -boot c -bootdisk scsi0 | ||
| # Set a serial console for better proxmox access. | ||
| qm set $INSTANCE_ID -serial0 socket -vga serial0 | ||
| # Setup bridged network for the VM. | ||
| qm set $INSTANCE_ID -net0 virtio,bridge=vmbr0 | ||
| # Enable QEMU Agent support for this VM (mandatory). | ||
| qm set $INSTANCE_ID -agent 1 | ||
| # Convert VM to tempate. | ||
| qm template $INSTANCE_ID | ||
| # Make VM template available on any node, not just were it was created. | ||
| ha-manager add vm:$INSTANCE_ID -state stopped | ||
| ``` | ||
|
|
||
| ### Cloud-init user-data | ||
|
|
||
| Proxmox currently does not support the upload of "snippets" via API, but these snippets are used for | ||
| cloud-init user-data which are required for the machine-controller to function. This provider | ||
| implementation needs to copy the generated user-data yaml file via SFTP to every proxmox node where | ||
| a VM is created or migrated to. For this to work, make sure that: | ||
|
|
||
| * A storage is enabled for content `snippets` (e.g. `local`) | ||
| * You have the SSH private key of a user that exists on all nodes which has write permission to the | ||
| path where snippets are stored (e.g. `/var/lib/vz/snippets`) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| # If you change the namespace/name, you must also | ||
| # adjust the rbac rules | ||
| name: machine-controller-proxmox | ||
| namespace: kube-system | ||
| type: Opaque | ||
| stringData: | ||
| token: << PM_API_TOKEN >> | ||
| sshPrivateKey: | | ||
| -----BEGIN OPENSSH PRIVATE KEY----- | ||
| ... | ||
| -----END OPENSSH PRIVATE KEY----- | ||
| --- | ||
| apiVersion: "cluster.k8s.io/v1alpha1" | ||
| kind: MachineDeployment | ||
| metadata: | ||
| name: proxmox-machinedeployment | ||
| namespace: kube-system | ||
| spec: | ||
| paused: false | ||
| replicas: 1 | ||
| strategy: | ||
| type: RollingUpdate | ||
| rollingUpdate: | ||
| maxSurge: 1 | ||
| maxUnavailable: 0 | ||
| minReadySeconds: 0 | ||
| selector: | ||
| matchLabels: | ||
| foo: bar | ||
| template: | ||
| metadata: | ||
| labels: | ||
| foo: bar | ||
| spec: | ||
| providerSpec: | ||
| value: | ||
| sshPublicKeys: | ||
| - "<< YOUR_PUBLIC_KEY >>" | ||
wozniakjan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cloudProvider: "proxmox" | ||
| cloudProviderSpec: | ||
| # Can also be set via the env var 'PM_API_ENDPOINT' on the machine-controller | ||
| # example: 'https://10.0.1.5/api2/json' | ||
| endpoint: '<< PM_API_ENDPOINT >>' | ||
| # Can also be set via the env var 'PM_API_USER_ID' on the machine-controller | ||
| userID: '<< PM_API_USER_ID >>' | ||
| # Can also be set via the env var 'PM_API_TOKEN' on the machine-controller | ||
| token: | ||
| secretKeyRef: | ||
| namespace: kube-system | ||
| name: machine-controller-proxmox | ||
| key: token | ||
| # Optional: Allow insecure connections to endpoint if no valid TLS certificate is | ||
| # presented. Can also be set via the env var 'PM_TLS_INSECURE' on the machine-controller | ||
| allowInsecure: true | ||
| # Optional: Connect through a proxy | ||
| # Can also be set via the env var 'PM_PROXY_URL' on the machine-controller | ||
| # proxyURL: '<< PM_PROXY_URL >>' | ||
| # SSH private key of a user that has write access to local storage on all nodes. this | ||
| # is needed to push cloud-init userdata. | ||
| ciStorageSSHPrivateKey: | ||
| secretKeyRef: | ||
| namespace: kube-system | ||
| name: machine-controller-proxmox | ||
| key: sshPrivateKey | ||
| ciStorageName: local | ||
| ciStoragePath: /var/lib/vz | ||
| # Can also be set via the env | ||
| # ID of the VM template | ||
| vmTemplateID: 9000 | ||
| # Sets the CPU count for this VM | ||
| cpuSockets: 2 | ||
| # Sets the CPU cores per CPU | ||
| cpuCores: 1 | ||
| # Memory configuration in MiB | ||
| memoryMB: 2048 | ||
| # Optional: Set up system disk size in GB. If not set, will be based on disk size in vm | ||
| # template. Cannot be smaller than the initial disk size in vm template. | ||
| diskSizeGB: 20 | ||
| # Optional: Name of the disk used in the vm template. | ||
| diskName: scsi0 | ||
| operatingSystem: "ubuntu" | ||
| operatingSystemSpec: | ||
| distUpgradeOnBoot: false | ||
| disableAutoUpdate: true | ||
| versions: | ||
| kubelet: 1.22.5 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nitpick: I think a link to the qm tool would be useful. Maybe it could be easily integrated like this