Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Documentation/design/installconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ type LibvirtNetwork struct {
Name string `json:"name"`
// IfName is the name of the network interface.
IfName string `json:"if"`
// DNSServer is the name of the DNS server.
DNSServer string `json:"resolver"`
// IPRange is the range of IPs to use.
IPRange string `json:"ipRange"`
}
Expand Down
2 changes: 1 addition & 1 deletion Documentation/dev/libvirt-howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ echo server=/tt.testing/192.168.124.1 | sudo tee /etc/NetworkManager/dnsmasq.d/t
1. Make sure you have the `virsh` binary installed: `sudo dnf install libvirt-client libvirt-devel`
2. Install the libvirt terraform provider:
```sh
GOBIN=~/.terraform.d/plugins go get -u github.com/dmacvicar/terraform-provider-libvirt
GOBIN=~/.terraform.d/plugins go get github.com/crawford/terraform-provider-libvirt
```

#### 1.9 Cache terrafrom plugins (optional, but makes subsequent runs a bit faster)
Expand Down
1 change: 1 addition & 0 deletions examples/tectonic.libvirt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ libvirt:
network:
name: tectonic
ifName: tt0
dnsServer: 8.8.8.8
ipRange: 192.168.124.0/24
imagePath: /path/to/image

Expand Down
3 changes: 2 additions & 1 deletion installer/pkg/config/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ var defaultCluster = Cluster{
},
Libvirt: libvirt.Libvirt{
Network: libvirt.Network{
IfName: libvirt.DefaultIfName,
DNSServer: libvirt.DefaultDNSServer,
IfName: libvirt.DefaultIfName,
},
},
Networking: Networking{
Expand Down
9 changes: 6 additions & 3 deletions installer/pkg/config/libvirt/libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

const (
// DefaultDNSServer is the default DNS server for libvirt.
DefaultDNSServer = "8.8.8.8"
// DefaultIfName is the default interface name for libvirt.
DefaultIfName = "osbr0"
)
Expand All @@ -24,9 +26,10 @@ type Libvirt struct {

// Network describes a libvirt network configuration.
type Network struct {
Name string `json:"tectonic_libvirt_network_name,omitempty" yaml:"name"`
IfName string `json:"tectonic_libvirt_network_if,omitempty" yaml:"ifName"`
IPRange string `json:"tectonic_libvirt_ip_range,omitempty" yaml:"ipRange"`
Name string `json:"tectonic_libvirt_network_name,omitempty" yaml:"name"`
IfName string `json:"tectonic_libvirt_network_if,omitempty" yaml:"ifName"`
DNSServer string `json:"tectonic_libvirt_resolver,omitempty" yaml:"dnsServer"`
IPRange string `json:"tectonic_libvirt_ip_range,omitempty" yaml:"ipRange"`
}

// TFVars fills in computed Terraform variables.
Expand Down
3 changes: 3 additions & 0 deletions installer/pkg/config/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ func (c *Cluster) validateLibvirt() []error {
if err := validate.PrefixError("libvirt network ifName", validate.NonEmpty(c.Libvirt.Network.IfName)); err != nil {
errs = append(errs, err)
}
if err := validate.PrefixError("libvirt network dnsServer", validate.IPv4(c.Libvirt.Network.DNSServer)); err != nil {
errs = append(errs, err)
}
errs = append(errs, c.validateOverlapWithPodOrServiceCIDR(c.Libvirt.Network.IPRange, "libvirt ipRange")...)
return errs
}
Expand Down
35 changes: 20 additions & 15 deletions installer/pkg/config/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,10 @@ func TestValidateLibvirt(t *testing.T) {
cluster: Cluster{
Libvirt: libvirt.Libvirt{
Network: libvirt.Network{
Name: "tectonic",
IfName: libvirt.DefaultIfName,
IPRange: "10.0.1.0/24",
Name: "tectonic",
IfName: libvirt.DefaultIfName,
DNSServer: libvirt.DefaultDNSServer,
IPRange: "10.0.1.0/24",
},
QCOWImagePath: fInvalid.Name(),
URI: "baz",
Expand All @@ -589,9 +590,10 @@ func TestValidateLibvirt(t *testing.T) {
cluster: Cluster{
Libvirt: libvirt.Libvirt{
Network: libvirt.Network{
Name: "tectonic",
IfName: libvirt.DefaultIfName,
IPRange: "10.0.1.0/24",
Name: "tectonic",
IfName: libvirt.DefaultIfName,
DNSServer: libvirt.DefaultDNSServer,
IPRange: "10.0.1.0/24",
},
QCOWImagePath: fValid.Name(),
URI: "baz",
Expand All @@ -604,9 +606,10 @@ func TestValidateLibvirt(t *testing.T) {
cluster: Cluster{
Libvirt: libvirt.Libvirt{
Network: libvirt.Network{
Name: "tectonic",
IfName: libvirt.DefaultIfName,
IPRange: "10.2.1.0/24",
Name: "tectonic",
IfName: libvirt.DefaultIfName,
DNSServer: libvirt.DefaultDNSServer,
IPRange: "10.2.1.0/24",
},
QCOWImagePath: fValid.Name(),
URI: "baz",
Expand All @@ -619,9 +622,10 @@ func TestValidateLibvirt(t *testing.T) {
cluster: Cluster{
Libvirt: libvirt.Libvirt{
Network: libvirt.Network{
Name: "tectonic",
IfName: libvirt.DefaultIfName,
IPRange: "x",
Name: "tectonic",
IfName: libvirt.DefaultIfName,
DNSServer: libvirt.DefaultDNSServer,
IPRange: "x",
},
QCOWImagePath: "foo",
URI: "baz",
Expand All @@ -634,9 +638,10 @@ func TestValidateLibvirt(t *testing.T) {
cluster: Cluster{
Libvirt: libvirt.Libvirt{
Network: libvirt.Network{
Name: "tectonic",
IfName: libvirt.DefaultIfName,
IPRange: "192.168.0.1/24",
Name: "tectonic",
IfName: libvirt.DefaultIfName,
DNSServer: "foo",
IPRange: "192.168.0.1/24",
},
QCOWImagePath: "foo",
URI: "baz",
Expand Down
1 change: 1 addition & 0 deletions installer/pkg/workflow/fixtures/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
],
"tectonic_ignition_worker": "worker.ign",
"tectonic_libvirt_network_if": "osbr0",
"tectonic_libvirt_resolver": "8.8.8.8",
"tectonic_master_count": 2,
"tectonic_cluster_name": "aws-basic",
"tectonic_networking": "canal",
Expand Down
3 changes: 2 additions & 1 deletion pkg/asset/installconfig/installconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ func TestInstallConfigGenerate(t *testing.T) {
network:
if: ""
ipRange: ""
name: ""`,
name: ""
resolver: ""`,
},
}
for _, tc := range cases {
Expand Down
2 changes: 2 additions & 0 deletions pkg/types/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ type LibvirtNetwork struct {
Name string `json:"name"`
// IfName is the name of the network interface.
IfName string `json:"if"`
// DNSServer is the name of the DNS server.
DNSServer string `json:"resolver"`
// IPRange is the range of IPs to use.
IPRange string `json:"ipRange"`
}
20 changes: 10 additions & 10 deletions steps/infra/libvirt/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ resource "libvirt_network" "tectonic_net" {
"${var.tectonic_libvirt_ip_range}",
]

dns = [{
local_only = true

hosts = ["${flatten(list(
data.libvirt_network_dns_host_template.bootstrap.*.rendered,
data.libvirt_network_dns_host_template.masters.*.rendered,
data.libvirt_network_dns_host_template.etcds.*.rendered,
data.libvirt_network_dns_host_template.workers.*.rendered,
))}"]
}]
dns_forwarder {
address = "${var.tectonic_libvirt_resolver}"
}

dns_host = ["${flatten(list(
data.libvirt_network_dns_host_template.bootstrap.*.rendered,
data.libvirt_network_dns_host_template.masters.*.rendered,
data.libvirt_network_dns_host_template.etcds.*.rendered,
data.libvirt_network_dns_host_template.workers.*.rendered,
))}"]

autostart = true
}
Expand Down
5 changes: 5 additions & 0 deletions steps/variables-libvirt.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ variable "tectonic_libvirt_ip_range" {
description = "IP range for the libvirt machines"
}

variable "tectonic_libvirt_resolver" {
type = "string"
description = "the upstream dns resolver"
}

variable "tectonic_coreos_qcow_path" {
type = "string"
description = "path to a container linux qcow image"
Expand Down