Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Question regarding creating Azure VMSS by using provider-jet-azure - v0.10.0-preview #192

Open
lioryantov opened this issue Jun 24, 2022 · 1 comment

Comments

@lioryantov
Copy link

lioryantov commented Jun 24, 2022

Hi,

I am trying to create Azure VMSS by using provider-jet-azure - v0.10.0-preview:
https://doc.crds.dev/github.com/crossplane-contrib/provider-jet-azure/compute.azure.jet.crossplane.io/LinuxVirtualMachineScaleSet/v1alpha1@v0.10.0-preview

And I have issue to create resource with custom_data like we have in Terraform module :
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine_scale_set#custom_data
Based on TF docs we can use base64 encoded file (for example cloud-init.tpl file).

When in provider-jet-azure - v0.10.0-preview I should provide custom_data as secret (by the way not clear why it should be secret and not path to file or ConfigMap):

ddd

I am trying to create secret with base64 encoded file and I am getting an error:
Message: create failed: cannot apply: apply failed: creating Linux Virtual Machine Scale Set "lior-vmss" (Resource Group "lior-rg"): compute.VirtualMachineScaleSetsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="InvalidParameter" Message="Custom data in OSProfile must be in Base64 encoding and with a maximum length of 87380 characters." Target="customData": : File name: main.tf.json

$ base64 cloudinit.tpl > cloudinit.tpl.base64
$  kubectl create secret generic cloudinit-secret -n crossplane-system --from-file=cloudinit=./cloudinit.tpl.base64
$ cat linuxvirtualmachinescaleset.yaml
---
apiVersion: compute.azure.jet.crossplane.io/v1alpha1
kind: LinuxVirtualMachineScaleSet
metadata:
  name: lior-vmss
spec:
  forProvider:
    adminUsername: adminuser
    adminPasswordSecretRef:
      key: adminpass
      name: vmss-secret
      namespace: crossplane-system
    instances: 1
    location: EAST US 2
    name: lior-vmss
    disablePasswordAuthentication: false
    customDataSecretRef:
      key: cloudinit
      name: cloudinit-secret
      namespace: crossplane-system
    networkInterface:
    - ipConfiguration:
      - name: internal
        primary: true
        subnetId: "/subscriptions/*************************/resourceGroups/lior-rg/providers/Microsoft.Network/virtualNetworks/liorvnet/subnets/liorsubnet"
      name: example
      primary: true
    osDisk:
    - caching: ReadWrite
      storageAccountType: Standard_LRS
    resourceGroupName: lior-rg
    sku: Standard_F2
    sourceImageReference:
    - offer: UbuntuServer
      publisher: Canonical
      sku: 16.04-LTS
      version: latest
  providerConfigRef:
    name: azure-jet-provider-config

Please assist or forward my question to technical specialist that can provide help.
Will be highly appreciated.

@lioryantov
Copy link
Author

lioryantov commented Jun 26, 2022

Update: I succeeded to resolve the issue by doing encode twice to my "cloudinit.tpl" script to base64:

apiVersion: v1
kind: Secret
metadata:
  name: cloudinit-secret
  namespace: crossplane-system
type: Opaque
data:
  cloudinit.tpl: |
    STJOc2IzVmtMV052Ym1acFp3b2dJQ0FnY0dGamEyRm5aVjkxY0dkeVlXUmxPaUIwY25WbENpQWdJQ0J3WVdOcllX .....

And my customDataSecretRef section looks like this:

customDataSecretRef:
    key: cloudinit.tpl
    name: cloudinit-secret
    namespace: crossplane-system

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant