Skip to content
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

Add KubeVirt platform support #725

Merged
merged 1 commit into from
Mar 31, 2022
Merged

Add KubeVirt platform support #725

merged 1 commit into from
Mar 31, 2022

Conversation

rmohr
Copy link
Member

@rmohr rmohr commented Mar 18, 2022

KubeVirt always exposes instance_id and hostname. Optionally ssh
keys may be provided by the platform matadata.

xref coreos/fedora-coreos-tracker#1126

Copying the resulting binary in a fcos VM on kubevirt yields this:

[core@vmi-fedora ~]$ sudo ./afterburn --provider kubevirt --hostname blub
Mar 25 11:17:47.276 INFO wrote hostname vmi-fedora to blub
[core@vmi-fedora ~]$ cat blub 
vmi-fedora
[core@vmi-fedora ~]$ sudo ./afterburn --provider kubevirt --attributes attrs
[core@vmi-fedora ~]$ cat attrs 
AFTERBURN_KUBEVIRT_INSTANCE_TYPE=myflavour
AFTERBURN_KUBEVIRT_INSTANCE_ID=8b5ea8f7-f7f2-48c8-a471-9a687302eb65
AFTERBURN_KUBEVIRT_HOSTNAME=vmi-fedora
[core@vmi-fedora ~]$ rm /home/core/.ssh/authorized_keys.d/afterburn
[core@vmi-fedora ~]$ sudo ./afterburn --provider kubevirt --ssh-keys core
[core@vmi-fedora ~]$ cat /home/core/.ssh/authorized_keys.d/afterburn
ssh-rsa AAAAB3...

For reference the VMI spec used to let kubevirt inject the data:

---
apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
  labels:
    special: vmi-fedora
  name: vmi-fedora
spec:
  domain:
    devices:
      disks:
      - disk:
          bus: virtio
        name: containerdisk
      - disk:
          bus: virtio
        name: cloudinitdisk
      rng: {}
    resources:
      requests:
        memory: 1024M
  terminationGracePeriodSeconds: 0
  accessCredentials:
  - sshPublicKey:
      source:
        secret:
          secretName: my-pub-key
      propagationMethod:
        configDrive: {}
  volumes:
  - containerDisk:
      image: quay.io/rmohr/rhcostest:35.20220316.dev.0-x86_64
    name: containerdisk
  - name: cloudinitdisk
    cloudInitConfigDrive:
      userData: |-
        {
          "ignition": {
            "version": "3.3.0"
          },
          "passwd": {
            "users": [
              {
                "name": "core",
                "sshAuthorizedKeys": [
                  "ssh-rsa AAAAB3..."
                ]
              }
            ]
          }
        }

This part

  - sshPublicKey:
      source:
        secret:
          secretName: my-pub-key
      propagationMethod:
        configDrive: {}

is responsible for injecting via config-drive metadata the ssh public keys in the secret my-pub-key.

@rmohr
Copy link
Member Author

rmohr commented Mar 21, 2022

/cc @bgilbert

Copy link
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM generally; two tiny nits and a question.

docs/usage/attributes.md Show resolved Hide resolved
src/providers/kubevirt/mod.rs Outdated Show resolved Hide resolved
src/providers/kubevirt/mod.rs Outdated Show resolved Hide resolved
@rmohr rmohr force-pushed the kubevirt branch 2 times, most recently from 4e503c5 to 3771956 Compare March 25, 2022 10:31
Copy link
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

src/providers/kubevirt/mod.rs Outdated Show resolved Hide resolved
@bgilbert bgilbert closed this Mar 25, 2022
@bgilbert bgilbert reopened this Mar 25, 2022
@bgilbert
Copy link
Contributor

Also, looks like mod.rs needs to be reformatted.

KubeVirt always exposes `instance_id` and `hostname`. Optionally
`instance_type`. ssh keys may be provided by the platform matadata.

Signed-off-by: Roman Mohr <rmohr@redhat.com>
@rmohr
Copy link
Member Author

rmohr commented Mar 28, 2022

Also, looks like mod.rs needs to be reformatted.

Hm, neiter cargo fmt, nor rustfmt produced any diff. cargo fmt -- --check -l returns locally for me with 0 exit code. Tried versions 1.59.0 and 1.57.0 (the one in the github workflow?) and 1.49.0 :/

@rmohr
Copy link
Member Author

rmohr commented Mar 29, 2022

@bgilbert could you allow CI to run? It may help me with the fmt issue which you raised.

Copy link
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, tests seem happy now.

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

Successfully merging this pull request may close these issues.

None yet

2 participants