[fix] - CloudInit - #1012
Conversation
|
""" WalkthroughThe VirtualMachine Helm template was updated to refine the conditional logic for including SSH keys and cloud-init configuration. The changes separate handling for SSH keys and cloud-init, adjust the inclusion of disks and volumes, and improve the inline cloud-init user data generation. Formatting improvements were also made. Additionally, the installer image tag for Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant HelmTemplate
participant VMResource
User->>HelmTemplate: Provide .Values (sshKeys, cloudInit)
HelmTemplate->>HelmTemplate: Evaluate .Values.sshKeys and .Values.cloudInit
alt Both sshKeys and cloudInit present
HelmTemplate->>VMResource: Add cloudinitdisk referencing secret with user "ubuntu" and SSH keys
HelmTemplate->>VMResource: Add accessCredentials block
else Only sshKeys present
HelmTemplate->>VMResource: Add cloudinitdisk generating inline user data with SSH keys
HelmTemplate->>VMResource: Add accessCredentials block
else Neither present
HelmTemplate->>VMResource: Add minimal cloudinitdisk with basic userData
HelmTemplate->>VMResource: Exclude accessCredentials block
end
Possibly related PRs
Suggested labels
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/apps/virtual-machine/templates/vm.yaml (1)
116-146: Consider DRY-ing duplicated inline CloudInit userData
Both conditional blocks (lines 116–131 and 133–146) repeat the same inlineusersandchpasswdconfiguration. You could consolidate them into a singleif .Values.sshKeysblock with a nested condition forsecretRefto reduce duplication.- {{- if and .Values.sshKeys .Values.cloudInit }} - - name: cloudinitdisk - cloudInitNoCloud: - secretRef: - name: {{ include "virtual-machine.fullname" . }}-cloud-init - userData: | - {{ printf "%s" "#cloud-config" }} - ... (ssh keys & chpasswd) - {{- end }} - {{- if and .Values.sshKeys (not .Values.cloudInit) }} - - name: cloudinitdisk - cloudInitNoCloud: - userData: | - {{ printf "%s" "#cloud-config" }} - ... (ssh keys & chpasswd) - {{- end }} + {{- if .Values.sshKeys }} + - name: cloudinitdisk + cloudInitNoCloud: + {{- if .Values.cloudInit }} + secretRef: + name: {{ include "virtual-machine.fullname" . }}-cloud-init + {{- end }} + userData: | + {{ printf "%s" "#cloud-config" }} + users: + - name: ubuntu + ssh_authorized_keys: | + {{- range .Values.sshKeys }} + {{ . }} + {{- end }} + chpasswd: + expire: false + {{- end }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/apps/virtual-machine/templates/vm.yaml(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build
🔇 Additional comments (7)
packages/apps/virtual-machine/templates/vm.yaml (7)
16-16: Approve formatting: inserted blank line for readability
The extra blank line after therunningfield improves separation of spec sections.
27-27: Approve formatting: inserted blank line for readability
The blank line beforedataVolumeTemplatesenhances visual structure.
80-80: Approve formatting: inserted blank line beforedisksblock
Additional whitespace aids clarity of device sections.
85-89: Disk inclusion condition now only checks for SSH keys
Thecloudinitdiskis now added only when.Values.sshKeysis provided (dropping the previous.Values.cloudInitcheck), aligning with the requirement to skip CloudInit when no SSH keys exist.Please confirm that skipping the CloudInit disk when only
.Values.cloudInitis set (and no SSH keys) is the intended behavior.
98-107: Access credentials block gated on SSH keys
Replacing the earlierwithblock, theaccessCredentialssection is now rendered only when.Values.sshKeysis set, matching the refined logic.
116-131: Render CloudInit volume with secretRef and embedded SSH keys when both SSH and CloudInit are present
This block mounts the CloudInit secret (-cloud-init) and injects the SSH keys inline, disabling password expiration. It correctly handles the combined SSH+CloudInit scenario.
133-146: Render inline CloudInit volume when only SSH keys are present
The template now generates a minimalcloudInitNoCloudvolume with embedded SSH keys and disabled password expiration when.Values.cloudInitis not provided.
dde4d78 to
b5a226a
Compare
b5a226a to
e1e93b1
Compare
e1e93b1 to
d35ff17
Compare
If SSH key and CloudInit provided - proceed
If ssh key provided but not CloudInit - proceed
Otherwise skip CloudInit section
Summary by CodeRabbit