Skip to content
Merged
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
20 changes: 11 additions & 9 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ var (
type ClusterConfig struct {
URL string `yaml:"url"`

ClusterCIDR string `yaml:"clusterCIDR"`
ServiceCIDR string `yaml:"serviceCIDR"`
DNS string `yaml:"dns"`
Domain string `yaml:"domain"`
ClusterCIDR string `yaml:"clusterCIDR"`
ServiceCIDR string `yaml:"serviceCIDR"`
ServiceNodePortRange string `yaml:"serviceNodePortRange"`
DNS string `yaml:"dns"`
Domain string `yaml:"domain"`
}

type ControlPlaneConfig struct {
Expand Down Expand Up @@ -82,11 +83,12 @@ func NewMicroshiftConfig() *MicroshiftConfig {
NodeName: nodeName,
NodeIP: nodeIP,
Cluster: ClusterConfig{
URL: "https://127.0.0.1:6443",
ClusterCIDR: "10.42.0.0/16",
ServiceCIDR: "10.43.0.0/16",
DNS: "10.43.0.10",
Domain: "cluster.local",
URL: "https://127.0.0.1:6443",
ClusterCIDR: "10.42.0.0/16",
ServiceCIDR: "10.43.0.0/16",
ServiceNodePortRange: "30000-32767",
DNS: "10.43.0.10",
Domain: "cluster.local",
},
ControlPlane: ControlPlaneConfig{},
Node: NodeConfig{},
Expand Down
25 changes: 15 additions & 10 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ func TestCommandLineConfig(t *testing.T) {
NodeName: "node1",
NodeIP: "1.2.3.4",
Cluster: ClusterConfig{
URL: "https://1.2.3.4:6443",
ClusterCIDR: "10.20.30.40/16",
ServiceCIDR: "40.30.20.10/16",
DNS: "cluster.dns",
Domain: "cluster.local",
URL: "https://1.2.3.4:6443",
ClusterCIDR: "10.20.30.40/16",
ServiceCIDR: "40.30.20.10/16",
ServiceNodePortRange: "1024-32767",
DNS: "cluster.dns",
Domain: "cluster.local",
},
},
err: nil,
Expand All @@ -70,6 +71,7 @@ func TestCommandLineConfig(t *testing.T) {
flags.StringVar(&config.Cluster.URL, "cluster-url", "", "")
flags.StringVar(&config.Cluster.ClusterCIDR, "cluster-cidr", "", "")
flags.StringVar(&config.Cluster.ServiceCIDR, "service-cidr", "", "")
flags.StringVar(&config.Cluster.ServiceNodePortRange, "service-node-port-range", "", "")
flags.StringVar(&config.Cluster.DNS, "cluster-dns", "", "")
flags.StringVar(&config.Cluster.Domain, "cluster-domain", "", "")

Expand All @@ -84,6 +86,7 @@ func TestCommandLineConfig(t *testing.T) {
"--cluster-url=" + tt.config.Cluster.URL,
"--cluster-cidr=" + tt.config.Cluster.ClusterCIDR,
"--service-cidr=" + tt.config.Cluster.ServiceCIDR,
"--service-node-port-range=" + tt.config.Cluster.ServiceNodePortRange,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we verify the value with a regex to avoid bleeding errors through (harder to track)?

That would probably apply to other parameters btw, so not high prio.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-reading the tests, I don't think we expose all these flags via cobra command. So we should do a clean up in a later PR.

"--cluster-dns=" + tt.config.Cluster.DNS,
"--cluster-domain=" + tt.config.Cluster.Domain,
})
Expand Down Expand Up @@ -120,11 +123,12 @@ func TestEnvironmentVariableConfig(t *testing.T) {
NodeName: "node1",
NodeIP: "1.2.3.4",
Cluster: ClusterConfig{
URL: "https://cluster.com:4343/endpoint",
ClusterCIDR: "10.20.30.40/16",
ServiceCIDR: "40.30.20.10/16",
DNS: "10.43.0.10",
Domain: "cluster.local",
URL: "https://cluster.com:4343/endpoint",
ClusterCIDR: "10.20.30.40/16",
ServiceCIDR: "40.30.20.10/16",
ServiceNodePortRange: "1024-32767",
DNS: "10.43.0.10",
Domain: "cluster.local",
},
},
err: nil,
Expand All @@ -142,6 +146,7 @@ func TestEnvironmentVariableConfig(t *testing.T) {
{"MICROSHIFT_CLUSTER_URL", "https://cluster.com:4343/endpoint"},
{"MICROSHIFT_CLUSTER_CLUSTERCIDR", "10.20.30.40/16"},
{"MICROSHIFT_CLUSTER_SERVICECIDR", "40.30.20.10/16"},
{"MICROSHIFT_CLUSTER_SERVICENODEPORTRANGE", "1024-32767"},
{"MICROSHIFT_CLUSTER_DNS", "10.43.0.10"},
{"MICROSHIFT_CLUSTER_DOMAIN", "cluster.local"},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/kube-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (s *KubeAPIServer) configure(cfg *config.MicroshiftConfig) {
"--service-account-key-file=" + cfg.DataDir + "/resources/kube-apiserver/secrets/service-account-key/service-account.crt",
"--service-account-signing-key-file=" + cfg.DataDir + "/resources/kube-apiserver/secrets/service-account-key/service-account.key",
"--service-cluster-ip-range=" + cfg.Cluster.ServiceCIDR,
"--service-node-port-range=" + cfg.Cluster.ServiceNodePortRange,
"--storage-backend=etcd3",
"--tls-cert-file=" + cfg.DataDir + "/certs/kube-apiserver/secrets/service-network-serving-certkey/tls.crt",
"--tls-private-key-file=" + cfg.DataDir + "/certs/kube-apiserver/secrets/service-network-serving-certkey/tls.key",
Expand Down