Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3a6d43f
OCPEDGE-2037: Add certificate authority controller
pacevedom Oct 6, 2025
dbf5715
OCPEDGE-2037: Add kubelet bootstrap functions for config handling
pacevedom Oct 6, 2025
d8d676c
OCPEDGE-2037: Configure kubelet to use bootstrap kubeconfig if present
pacevedom Oct 6, 2025
9297227
OCPEDGE-2037: Clean up kubelet config assets
pacevedom Oct 6, 2025
b643256
OCPEDGE-2037: Add node ip address to etcd certificates
pacevedom Oct 6, 2025
a22067f
OCPEDGE-2037: Start CA controller
pacevedom Oct 7, 2025
0b5bac1
OCPEDGE-2037: Update etcd serving configuration
pacevedom Oct 7, 2025
9ba4405
OCPEDGE-2037: Add etcd config file
pacevedom Oct 7, 2025
34ad026
OCPEDGE-2037: Update etcd controller readiness check
pacevedom Oct 7, 2025
21d7020
OCPEDGE-2037: Update multinode config
pacevedom Oct 7, 2025
fff7c2c
OCPEDGE-2037: Update apiserver controller configuration handling
pacevedom Oct 7, 2025
67074cf
OCPEDGE-2037: Add etcd-severs discovery to apiserver
pacevedom Oct 7, 2025
90e0820
OCPEDGE-2037: Add join-cluster command
pacevedom Oct 7, 2025
1fb73e0
OCPEDGE-2037: Skip join cluster if already a member
pacevedom Oct 7, 2025
2d3d3f2
OCPEDGE-2037: Improve etcd directory handling for join-cluster
pacevedom Oct 7, 2025
42b4152
OCPEDGE-2037: Add automatic cleanup of directories before joining
pacevedom Oct 7, 2025
03e3aa7
OCPEDGE-2037: Hide new join-cluster command
pacevedom Oct 7, 2025
89bf0e8
OCPEDGE-2037: Update logs and usage
pacevedom Oct 7, 2025
c439b3e
OCPEDGE-2037: Verify nits
pacevedom Oct 7, 2025
04f6424
OCPEDGE-2037: Handle ipv6 in etcd initial cluster
pacevedom Oct 7, 2025
d820dcd
OCPEDGE-2037: update prerun version check
pacevedom Oct 8, 2025
314da47
OCPEDGE-2037: Disable CA controller if not multinode
pacevedom Oct 8, 2025
f702b47
OCPEDGE-2037: Rename command to add-node
pacevedom Oct 8, 2025
a451b02
OCPEDGE-2037: Add service-account keys to controller
pacevedom Oct 10, 2025
3a9443e
OCPEDGE-2037: Enable leader-elect for kcm and ks
pacevedom Oct 10, 2025
b98ba18
OCPEDGE-2037: Nits
pacevedom Oct 14, 2025
6c44e28
OCPEDGE-2037: Improve etcd handling
pacevedom Oct 14, 2025
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
6 changes: 3 additions & 3 deletions assets/core/kubelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ featureGates:
APIPriorityAndFairness: true
DownwardAPIHugePages: true
PodSecurity: true
RotateKubeletServerCertificate: false # TODO
RotateKubeletServerCertificate: false
kubeAPIBurst: 100
kubeAPIQPS: 50
maxPods: 250
nodeStatusReportFrequency: 5m
rotateCertificates: false # TODO
rotateCertificates: false
serializeImagePulls: false
serverTLSBootstrap: false # TODO
serverTLSBootstrap: false
tlsCertFile: "{{ .tlsCertFile }}"
tlsCipherSuites: [{{ .tlsCipherSuites }}]
tlsMinVersion: "{{ .tlsMinVersion }}"
Expand Down
1 change: 1 addition & 0 deletions cmd/microshift/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ func newCommand() *cobra.Command {
cmd.AddCommand(cmds.NewBackupCommand())
cmd.AddCommand(cmds.NewRestoreCommand())
cmd.AddCommand(cmds.NewHealthcheckCommand())
cmd.AddCommand(cmds.NewAddNodeCommand())
return cmd
}
50 changes: 41 additions & 9 deletions etcd/cmd/microshift-etcd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"

Expand Down Expand Up @@ -75,20 +76,17 @@ func (s *EtcdService) configure(cfg *config.Config) {
// based on https://github.com/openshift/cluster-etcd-operator/blob/master/bindata/bootkube/bootstrap-manifests/etcd-member-pod.yaml#L19
s.etcdCfg = etcd.NewConfig()
s.etcdCfg.ClusterState = "new"
//s.etcdCfg.ForceNewCluster = true //TODO
s.etcdCfg.Logger = "zap"
s.etcdCfg.Dir = dataDir
s.etcdCfg.QuotaBackendBytes = cfg.Etcd.QuotaBackendBytes
url2380 := setURL([]string{"localhost"}, "2380")
url2379 := setURL([]string{"localhost"}, "2379")
s.etcdCfg.AdvertisePeerUrls = url2380
s.etcdCfg.ListenPeerUrls = url2380
s.etcdCfg.AdvertiseClientUrls = url2379
s.etcdCfg.ListenClientUrls = url2379
s.etcdCfg.ListenMetricsUrls = setURL([]string{"localhost"}, "2381")
s.etcdCfg.AdvertisePeerUrls = setURL([]string{cfg.Node.NodeIP}, "2380")
s.etcdCfg.ListenPeerUrls = setURL([]string{"0.0.0.0"}, "2380")
s.etcdCfg.AdvertiseClientUrls = setURL([]string{cfg.Node.NodeIP}, "2379")
s.etcdCfg.ListenClientUrls = setURL([]string{"0.0.0.0"}, "2379")
s.etcdCfg.ListenMetricsUrls = setURL([]string{cfg.Node.NodeIP}, "2381")

s.etcdCfg.Name = cfg.Node.HostnameOverride
s.etcdCfg.InitialCluster = fmt.Sprintf("%s=https://%s:2380", cfg.Node.HostnameOverride, "localhost")
s.etcdCfg.InitialCluster = fmt.Sprintf("%s=https://%s", cfg.Node.HostnameOverride, net.JoinHostPort(cfg.Node.NodeIP, "2380"))

s.etcdCfg.TlsMinVersion = getTLSMinVersion(cfg.ApiServer.TLS.MinVersion)
if cfg.ApiServer.TLS.MinVersion != string(configv1.VersionTLS13) {
Expand All @@ -103,6 +101,8 @@ func (s *EtcdService) configure(cfg *config.Config) {
s.etcdCfg.PeerTLSInfo.TrustedCAFile = etcdSignerCertPath

s.etcdCfg.ExperimentalMaxLearners = MaxLearners

updateConfigFromFile(s.etcdCfg, getConfigFilePath())
}

func (s *EtcdService) Run() error {
Expand Down Expand Up @@ -217,3 +217,35 @@ func checkFragmentationPercentage(ondisk, inuse int64) float64 {
fragmentedPercentage := (diff / float64(ondisk)) * 100
return math.Round(fragmentedPercentage*100) / 100
}

func getConfigFilePath() string {
return filepath.Join(config.DataDir, "etcd", "config")
}

func updateConfigFromFile(etcdCfg *etcd.Config, configPath string) {
data, err := os.ReadFile(configPath)
if err != nil {
klog.Errorf("failed to read config file: %v", err)
return
}
lines := strings.Split(string(data), "\n")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we control the file, why not use json?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Basically similarity with regular etcd files you can feed it, there is no other reason but using the same names to make it more understandable. I can swap it with json without trouble too.

for _, line := range lines {
line = strings.TrimSpace(line)
if line == "" || strings.HasPrefix(line, "#") {
continue
}
eqIdx := strings.Index(line, "=")
if eqIdx == -1 {
continue
}
parts := []string{line[:eqIdx], line[eqIdx+1:]}
key := strings.TrimSpace(parts[0])
val := strings.TrimSpace(parts[1])
switch key {
case "ETCD_INITIAL_CLUSTER":
etcdCfg.InitialCluster = val
case "ETCD_INITIAL_CLUSTER_STATE":
etcdCfg.ClusterState = val
}
}
}
21 changes: 3 additions & 18 deletions pkg/admin/prerun/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,9 @@ func getVersions() (versions, error) {
// error is something else than "file does not exist", like permissions
return versions{}, fmt.Errorf("failed to get version of existing MicroShift data: %w", err)
}

// Ignoring .nodename to not get false positives from mere existence of the path
dataExists, err := util.PathExistsAndIsNotEmpty(config.DataDir, ".nodename")
if err != nil {
return versions{}, err
}

if !dataExists {
// Data directory does not exist so it's first run of MicroShift
klog.InfoS("Version file does not exist yet - assuming first run of MicroShift")
vs.data = nil // repeated for clarity
return vs, nil
}

// Data exists but without version file, let's assume 4.13 and compare versions
klog.InfoS("MicroShift data directory exists, but doesn't contain version file" +
" - assuming 4.13.0 and proceeding with version compatibility checks")
vs.data = &versionMetadata{Major: 4, Minor: 13, Patch: 0}
// Data directory or version does not exist
klog.InfoS("Version file does not exist yet - assuming first run of MicroShift")
vs.data = nil // repeated for clarity
return vs, nil
}

Expand Down
Loading