Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fe58208
Go modules
nirarg Oct 19, 2020
e09e99f
Add terraform plugins for "kubernetes" and "kubevirt" resources
nirarg Oct 19, 2020
fc1133a
Add reviewers and approvers lists for kubevirt alias
nirarg Oct 19, 2020
04353c3
Add terraform data files for kubevirt provide
nirarg Oct 19, 2020
556204d
Add kubevirt provider tfvars
nirarg Oct 20, 2020
1056d7d
Add Kubevirt platform structs
nirarg Oct 20, 2020
04df193
Adding InfraCluster client, used by validations and destroy
nirarg Sep 21, 2020
63cb364
Add kubevirt platform defaults
nirarg Oct 5, 2020
d09442e
Add kubevirt platform validations
nirarg Oct 5, 2020
03b2c81
Add install-config logic for kubevirt platform
nirarg Oct 20, 2020
3daad51
Add machine (for controlplane) and machineset (for compute) to KubeVi…
nirarg Jul 5, 2020
01e1ca8
Add kubevirt platform manifests configurations
nirarg Aug 18, 2020
9285275
Kubevirt platform infrastructure and node network specific configurat…
nirarg Aug 18, 2020
a985307
Add kubevirt rhcos image
nirarg Jul 7, 2020
cef138f
Add kubevirt specific behavior for cluster assets generation
nirarg Jul 2, 2020
5f768ad
Add kubevirt platform gather info implementation (GatherKubevirt)
nirarg Sep 9, 2020
210bf31
Add the apiVIP to resolv.conf inside the bootstrab VM
nirarg Sep 9, 2020
2737fe4
Add destroy implementation for kubevirt platform
nirarg Oct 1, 2020
c9ba4c0
Create openshift-kubevirt-infra namespace
Nov 11, 2020
cffad55
Align user-data secret with other platforms
Nov 11, 2020
69245ca
Add role yaml with the minimum required permissions
nirarg Nov 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,15 @@ aliases:
- Gal-Zaidman
- rgolangh
- eslutsky
kubevirt-approvers:
- nirarg
- bardielle
- ravidbro
- rgolangh
- chenyosef
kubevirt-reviewers:
- nirarg
- bardielle
- ravidbro
- rgolangh
- chenyosef
1 change: 1 addition & 0 deletions cmd/openshift-install/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
_ "github.com/openshift/installer/pkg/destroy/baremetal"
"github.com/openshift/installer/pkg/destroy/bootstrap"
_ "github.com/openshift/installer/pkg/destroy/gcp"
_ "github.com/openshift/installer/pkg/destroy/kubevirt"
_ "github.com/openshift/installer/pkg/destroy/libvirt"
_ "github.com/openshift/installer/pkg/destroy/openstack"
_ "github.com/openshift/installer/pkg/destroy/ovirt"
Expand Down
8 changes: 8 additions & 0 deletions cmd/openshift-install/gather.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
gatherazure "github.com/openshift/installer/pkg/terraform/gather/azure"
gatherbaremetal "github.com/openshift/installer/pkg/terraform/gather/baremetal"
gathergcp "github.com/openshift/installer/pkg/terraform/gather/gcp"
gatherkubevirt "github.com/openshift/installer/pkg/terraform/gather/kubevirt"
gatherlibvirt "github.com/openshift/installer/pkg/terraform/gather/libvirt"
gatheropenstack "github.com/openshift/installer/pkg/terraform/gather/openstack"
gatherovirt "github.com/openshift/installer/pkg/terraform/gather/ovirt"
Expand All @@ -38,6 +39,7 @@ import (
azuretypes "github.com/openshift/installer/pkg/types/azure"
baremetaltypes "github.com/openshift/installer/pkg/types/baremetal"
gcptypes "github.com/openshift/installer/pkg/types/gcp"
kubevirttypes "github.com/openshift/installer/pkg/types/kubevirt"
libvirttypes "github.com/openshift/installer/pkg/types/libvirt"
openstacktypes "github.com/openshift/installer/pkg/types/openstack"
ovirttypes "github.com/openshift/installer/pkg/types/ovirt"
Expand Down Expand Up @@ -237,6 +239,12 @@ func extractHostAddresses(config *types.InstallConfig, tfstate *terraform.State)
if err != nil {
logrus.Error(err)
}
case kubevirttypes.Name:
bootstrap, err := gatherkubevirt.BootstrapIP(tfstate)
if err != nil {
return bootstrap, port, masters, err
}
masters, err = gatherkubevirt.ControlPlaneIPs(tfstate)
default:
return "", port, nil, errUnSupportedGatherPlatform{Message: fmt.Sprintf("Cannot fetch the bootstrap and control plane host addresses from state file for %s platform", config.Platform.Name())}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ then
copy_static_resources_for openstack
copy_static_resources_for ovirt
copy_static_resources_for vsphere
copy_static_resources_for kubevirt

cp mco-bootstrap/manifests/* manifests/

Expand Down
7 changes: 7 additions & 0 deletions data/data/bootstrap/kubevirt/OWNERS
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
2 changes: 2 additions & 0 deletions data/data/bootstrap/kubevirt/README.md
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
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
72 changes: 72 additions & 0 deletions data/data/install.openshift.io_installconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ spec:
type: string
type: array
type: object
kubevirt:
description: Kubevirt is the configuration used when installing on Kubevirt.
properties:
cpu:
description: CPU is the amount of CPUs used.
format: int32
type: integer
memory:
description: 'Memory is the size of a VM''s memory. Format: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go'
type: string
storageSize:
description: 'StorageSize is the size of VM''s boot volume. Format: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go'
type: string
type: object
libvirt:
description: Libvirt is the configuration used when installing on libvirt.
type: object
Expand Down Expand Up @@ -450,6 +464,20 @@ spec:
type: string
type: array
type: object
kubevirt:
description: Kubevirt is the configuration used when installing on Kubevirt.
properties:
cpu:
description: CPU is the amount of CPUs used.
format: int32
type: integer
memory:
description: 'Memory is the size of a VM''s memory. Format: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go'
type: string
storageSize:
description: 'StorageSize is the size of VM''s boot volume. Format: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go'
type: string
type: object
libvirt:
description: Libvirt is the configuration used when installing on libvirt.
type: object
Expand Down Expand Up @@ -1060,6 +1088,50 @@ spec:
- projectID
- region
type: object
kubevirt:
description: Kubevirt is the configuration used when installing on kubevirt.
properties:
apiVIP:
description: APIVIP is the virtual IP address for the api endpoint.
format: ip
type: string
defaultMachinePlatform:
description: DefaultMachinePlatform is the default configuration used when installing on Kubevirt for machine pools which do not define their own platform configuration.
properties:
cpu:
description: CPU is the amount of CPUs used.
format: int32
type: integer
memory:
description: 'Memory is the size of a VM''s memory. Format: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go'
type: string
storageSize:
description: 'StorageSize is the size of VM''s boot volume. Format: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go'
type: string
type: object
ingressVIP:
description: IngressIP is an external IP which routes to the default ingress controller.
format: ip
type: string
namespace:
description: Namespace is the namespace in the infra cluster, which the control plane (master vms) and the compute (worker vms) are installed in.
type: string
networkName:
description: NetworkName is the target network of all the network interfaces of the nodes.
type: string
persistentVolumeAccessMode:
default: ReadWriteMany
description: PersistentVolumeAccessMode is the access mode should be use with the persistent volumes.
type: string
storageClass:
description: StorageClass is the Storage Class used in the infra cluster.
type: string
required:
- apiVIP
- ingressVIP
- namespace
- networkName
type: object
libvirt:
description: Libvirt is the configuration used when installing on libvirt.
properties:
Expand Down
7 changes: 7 additions & 0 deletions data/data/kubevirt/OWNERS
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
135 changes: 135 additions & 0 deletions data/data/kubevirt/bootstrap/main.tf
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
}
}
}
}
}
}
}
63 changes: 63 additions & 0 deletions data/data/kubevirt/bootstrap/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
variable "cluster_id" {
description = "The ID of OpenShift cluster"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same

}

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 = {}
}
Loading