114 lines
2.7 KiB
Go
114 lines
2.7 KiB
Go
package templates
|
|
|
|
import (
|
|
"os"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
types "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
|
buildinfo "undecided.project/monok8s/pkg/buildinfo"
|
|
)
|
|
|
|
var ValAPIServerEndPoint string = "10.0.0.10:6443"
|
|
var ValHostname string = "monoks-master-1"
|
|
var ValBootstrapToken string = "abcd12.ef3456789abcdef0"
|
|
var ValDiscoveryTokenCACertHash string = "sha256:9f1c2b3a4d5e6f7890abc1234567890abcdef1234567890abcdef1234567890ab"
|
|
|
|
func init() {
|
|
ValBootstrapToken = os.Getenv("HOSTNAME")
|
|
ValBootstrapToken = os.Getenv("BOOTSTRAP_TOKEN")
|
|
ValDiscoveryTokenCACertHash = os.Getenv("TOKEN_CACERT_HASH")
|
|
ValAPIServerEndPoint = os.Getenv("API_SERVER_ENDPOINT")
|
|
}
|
|
|
|
func DefaultMonoKSConfig() types.MonoKSConfig {
|
|
return types.MonoKSConfig{
|
|
TypeMeta: metav1.TypeMeta{
|
|
APIVersion: "monok8s.io/v1alpha1",
|
|
Kind: "MonoKSConfig",
|
|
},
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "example",
|
|
Namespace: "kube-system",
|
|
},
|
|
Spec: types.MonoKSConfigSpec{
|
|
KubernetesVersion: buildinfo.Version,
|
|
NodeName: ValHostname,
|
|
|
|
ClusterRole: "control-plane",
|
|
InitControlPlane: true,
|
|
|
|
ClusterName: "monok8s",
|
|
ClusterDomain: "cluster.local",
|
|
|
|
PodSubnet: "10.244.0.0/16",
|
|
ServiceSubnet: "10.96.0.0/12",
|
|
|
|
APIServerAdvertiseAddress: "10.0.0.10",
|
|
APIServerEndpoint: ValAPIServerEndPoint,
|
|
|
|
// Fake token and hash for placeholder purpose
|
|
BootstrapToken: ValBootstrapToken,
|
|
DiscoveryTokenCACertHash: ValDiscoveryTokenCACertHash,
|
|
|
|
ContainerRuntimeEndpoint: "unix:///var/run/crio/crio.sock",
|
|
|
|
CNIPlugin: "default",
|
|
|
|
AllowSchedulingOnControlPlane: true,
|
|
SkipImageCheck: false,
|
|
|
|
KubeProxyNodePortAddresses: []string{
|
|
"primary",
|
|
},
|
|
|
|
SubjectAltNames: []string{
|
|
"10.0.0.10", "localhost", ValHostname,
|
|
},
|
|
|
|
NodeLabels: map[string]string{
|
|
"monok8s.io/label": "value",
|
|
},
|
|
|
|
NodeAnnotations: map[string]string{
|
|
"monok8s.io/annotation": "value",
|
|
},
|
|
|
|
Network: types.NetworkSpec{
|
|
Hostname: "monok8s-worker-1",
|
|
ManagementIface: "eth1",
|
|
ManagementCIDR: "10.0.0.10/24",
|
|
ManagementGW: "10.0.0.1",
|
|
DNSNameservers: []string{
|
|
"1.1.1.1",
|
|
"8.8.8.8",
|
|
},
|
|
DNSSearchDomains: []string{
|
|
"lan",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func DefaultOSUpgrade() types.OSUpgrade {
|
|
return types.OSUpgrade{
|
|
TypeMeta: metav1.TypeMeta{
|
|
APIVersion: "monok8s.io/v1alpha1",
|
|
Kind: "OSUpgrade",
|
|
},
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "example",
|
|
Namespace: "kube-system",
|
|
},
|
|
Spec: types.OSUpgradeSpec{
|
|
Version: "v0.0.1",
|
|
ImageURL: "https://example.invalid/images/monok8s-v0.0.1.img.zst",
|
|
TargetPartition: "B",
|
|
NodeSelector: []string{
|
|
ValHostname,
|
|
},
|
|
Force: false,
|
|
},
|
|
}
|
|
}
|