-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add KubeVirt platform as infrastructure for Openshift installation #4350
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
fe58208
Go modules
nirarg e09e99f
Add terraform plugins for "kubernetes" and "kubevirt" resources
nirarg fc1133a
Add reviewers and approvers lists for kubevirt alias
nirarg 04353c3
Add terraform data files for kubevirt provide
nirarg 556204d
Add kubevirt provider tfvars
nirarg 1056d7d
Add Kubevirt platform structs
nirarg 04df193
Adding InfraCluster client, used by validations and destroy
nirarg 63cb364
Add kubevirt platform defaults
nirarg d09442e
Add kubevirt platform validations
nirarg 03b2c81
Add install-config logic for kubevirt platform
nirarg 3daad51
Add machine (for controlplane) and machineset (for compute) to KubeVi…
nirarg 01e1ca8
Add kubevirt platform manifests configurations
nirarg 9285275
Kubevirt platform infrastructure and node network specific configurat…
nirarg a985307
Add kubevirt rhcos image
nirarg cef138f
Add kubevirt specific behavior for cluster assets generation
nirarg 5f768ad
Add kubevirt platform gather info implementation (GatherKubevirt)
nirarg 210bf31
Add the apiVIP to resolv.conf inside the bootstrab VM
nirarg 2737fe4
Add destroy implementation for kubevirt platform
nirarg c9ba4c0
Create openshift-kubevirt-infra namespace
cffad55
Align user-data secret with other platforms
69245ca
Add role yaml with the minimum required permissions
nirarg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
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,7 @@ | ||
| # See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md | ||
| # This file just uses aliases defined in OWNERS_ALIASES. | ||
|
|
||
| approvers: | ||
| - kubevirt-approvers | ||
| reviewers: | ||
| - kubevirt-reviewers |
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,2 @@ | ||
| KubeVirt needs the same assets during setup except for ironic. | ||
| Please refer to https://github.com/openshift/installer/tree/master/data/data/bootstrap/baremetal |
20 changes: 20 additions & 0 deletions
20
data/data/bootstrap/kubevirt/files/etc/NetworkManager/dispatcher.d/30-local-dns-prepender
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,20 @@ | ||
| #!/bin/bash | ||
| IFACE=$1 | ||
| STATUS=$2 | ||
| case "$STATUS" in | ||
| up|dhcp4-change|dhcp6-change) | ||
| logger -s "NM local-dns-prepender triggered by ${1} ${2}." | ||
| DNS_IP="127.0.0.1" | ||
| set +e | ||
| logger -s "NM local-dns-prepender: Checking if local DNS IP is the first entry in resolv.conf" | ||
| if grep nameserver /etc/resolv.conf | head -n 1 | grep -q "$DNS_IP" ; then | ||
| logger -s "NM local-dns-prepender: local DNS IP already is the first entry in resolv.conf" | ||
| exit 0 | ||
| else | ||
| logger -s "NM local-dns-prepender: Looking for '# Generated by NetworkManager' in /etc/resolv.conf to place 'nameserver $DNS_IP'" | ||
| sed -i "/^# Generated by.*$/a nameserver $DNS_IP" /etc/resolv.conf | ||
| fi | ||
| ;; | ||
| *) | ||
| ;; | ||
| esac |
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,7 @@ | ||
| # See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md | ||
| # This file just uses aliases defined in OWNERS_ALIASES. | ||
|
|
||
| approvers: | ||
| - kubevirt-approvers | ||
| reviewers: | ||
| - kubevirt-reviewers |
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,135 @@ | ||
| data "ignition_file" "hostname" { | ||
| mode = "420" | ||
| path = "/etc/hostname" | ||
|
|
||
| content { | ||
| content = <<EOF | ||
| ${var.cluster_id}-bootstrap | ||
| EOF | ||
| } | ||
| } | ||
|
|
||
| data "ignition_config" "bootstrap_ignition_config" { | ||
|
|
||
| merge { | ||
| source = "data:text/plain;charset=utf-8;base64,${base64encode(var.ignition_data)}" | ||
| } | ||
|
|
||
| files = [ | ||
| element(data.ignition_file.hostname.*.rendered, 0) | ||
| ] | ||
| } | ||
|
|
||
| resource "kubernetes_secret" "bootstrap_ignition" { | ||
| metadata { | ||
| name = "${var.cluster_id}-bootstrap-ignition" | ||
| namespace = var.namespace | ||
| labels = var.labels | ||
| } | ||
| data = { | ||
| "userdata" = element( | ||
| data.ignition_config.bootstrap_ignition_config.*.rendered, | ||
| 0, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| resource "kubevirt_virtual_machine" "bootstrap_vm" { | ||
|
|
||
| metadata { | ||
| name = "${var.cluster_id}-bootstrap" | ||
| namespace = var.namespace | ||
| labels = var.labels | ||
| } | ||
| spec { | ||
| run_strategy = "Always" | ||
| data_volume_templates { | ||
| metadata { | ||
| name = "${var.cluster_id}-bootstrap-bootvolume" | ||
| namespace = var.namespace | ||
| } | ||
| spec { | ||
| source { | ||
| pvc { | ||
| name = var.pvc_name | ||
| namespace = var.namespace | ||
| } | ||
| } | ||
| pvc { | ||
| access_modes = [var.pv_access_mode] | ||
| resources { | ||
| requests = { | ||
| storage = var.storage | ||
| } | ||
| } | ||
| storage_class_name = var.storage_class | ||
| } | ||
| } | ||
| } | ||
| template { | ||
| metadata { | ||
| labels = { | ||
| "kubevirt.io/vm" = "${var.cluster_id}-bootstrap" | ||
| } | ||
| } | ||
| spec { | ||
| volume { | ||
| name = "datavolumedisk1" | ||
| volume_source { | ||
| data_volume { | ||
| name = "${var.cluster_id}-bootstrap-bootvolume" | ||
| } | ||
| } | ||
| } | ||
| volume { | ||
| name = "cloudinitdisk" | ||
| volume_source { | ||
| cloud_init_config_drive { | ||
| user_data_secret_ref { | ||
| name = kubernetes_secret.bootstrap_ignition.metadata[0].name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| domain { | ||
| resources { | ||
| requests = { | ||
| memory = var.memory | ||
| cpu = var.cpu | ||
| } | ||
| } | ||
| devices { | ||
| disk { | ||
| name = "datavolumedisk1" | ||
| disk_device { | ||
| disk { | ||
| bus = "virtio" | ||
| } | ||
| } | ||
| } | ||
| disk { | ||
| name = "cloudinitdisk" | ||
| disk_device { | ||
| disk { | ||
| bus = "virtio" | ||
| } | ||
| } | ||
| } | ||
| interface { | ||
| name = "main" | ||
| interface_binding_method = "InterfaceBridge" | ||
| } | ||
| } | ||
| } | ||
| network { | ||
| name = "main" | ||
| network_source { | ||
| multus { | ||
| network_name = var.network_name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
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,63 @@ | ||
| variable "cluster_id" { | ||
| description = "The ID of OpenShift cluster" | ||
| } | ||
|
|
||
| variable "namespace" { | ||
| type = string | ||
| description = "The namespace/project in the infra cluster, in which all the tenant cluster resources should be created" | ||
| } | ||
|
|
||
| variable "storage" { | ||
| type = string | ||
| description = "bootstrap VM disk size, of type Quantity (see: https://github.com/kubernetes/apimachinery/blob/master/pkg/api/resource/quantity.go)" | ||
| default = "35Gi" | ||
| } | ||
|
|
||
| variable "memory" { | ||
| type = string | ||
| description = "bootstrap VM memory size, of type Quantity (see: https://github.com/kubernetes/apimachinery/blob/master/pkg/api/resource/quantity.go)" | ||
| default = "8G" | ||
| } | ||
|
|
||
| variable "cpu" { | ||
| type = string | ||
| description = "bootstrap VM number of cores" | ||
| default = "4" | ||
| } | ||
|
|
||
| variable "ignition_data" { | ||
| type = string | ||
| description = "Ignition config file contents of the bootstrap VM" | ||
| } | ||
|
|
||
| variable "storage_class" { | ||
| type = string | ||
| description = "The \"class\" of the storage located in the infra cluster" | ||
| } | ||
|
|
||
| variable "network_name" { | ||
| type = string | ||
| description = "The name of the sub network created in the infracluster which should be used by the tenant cluster resources" | ||
| } | ||
|
|
||
| variable "pv_access_mode" { | ||
| type = string | ||
| description = "The access mode which all the persistant volumes should be created with [ReadWriteOnce,ReadOnlyMany,ReadWriteMany]" | ||
| } | ||
|
|
||
| variable "pvc_name" { | ||
| type = string | ||
| description = "The Persistant data volume which bootstrap VM should be cloned from" | ||
| } | ||
|
|
||
| variable "labels" { | ||
| type = map(string) | ||
|
|
||
| description = <<EOF | ||
| (optional) Labels to be applied to created resources. | ||
|
|
||
| Example: `{ "key" = "value", "foo" = "bar" }` | ||
| EOF | ||
|
|
||
| default = {} | ||
| } | ||
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.
same