Skip to content

Commit

Permalink
Merge pull request kosmos-io#601 from village-way/release-0.4.0
Browse files Browse the repository at this point in the history
Cherry-Pick: connect to apiserver connection refused
  • Loading branch information
duanmengkk authored May 30, 2024
2 parents ab0d3ba + 162d006 commit fd0b73c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/kubenest/constants/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (

//controlplane apiserver
ApiServer = "apiserver"
ApiServerAnp = "apiserver-anp"
ApiServerReplicas = 1
ApiServerServiceSubnet = "10.237.6.0/18"
ApiServerEtcdListenClientPort = 2379
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubenest/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ func NewInitPhase(opts *InitOptions) *workflow.Phase {
initPhase.AppendTask(tasks.NewVirtualClusterApiserverTask())
initPhase.AppendTask(tasks.NewUploadKubeconfigTask())
initPhase.AppendTask(tasks.NewCheckApiserverHealthTask())
initPhase.AppendTask(tasks.NewAnpTask())
initPhase.AppendTask(tasks.NewComponentTask())
initPhase.AppendTask(tasks.NewCheckControlPlaneTask())
initPhase.AppendTask(tasks.NewAnpTask())
// create core-dns
initPhase.AppendTask(tasks.NewCoreDNSTask())
// add server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ kind: Deployment
metadata:
labels:
virtualCluster-app: apiserver
virtualCluster-anp: apiserver-anp
app.kubernetes.io/managed-by: virtual-cluster-controller
name: {{ .DeploymentName }}
namespace: {{ .Namespace }}
Expand All @@ -148,6 +149,7 @@ spec:
metadata:
labels:
virtualCluster-app: apiserver
virtualCluster-anp: apiserver-anp
spec:
automountServiceAccountToken: false
hostNetwork: true
Expand Down
20 changes: 19 additions & 1 deletion pkg/kubenest/tasks/anp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tasks
import (
"context"
"fmt"
apiclient "github.com/kosmos.io/kosmos/pkg/kubenest/util/api-client"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -43,7 +44,7 @@ func NewAnpTask() workflow.Task {
},
{
Name: "check-anp-health",
Run: runCheckVirtualClusterAPIServer,
Run: runCheckVirtualClusterAnp,
},
},
}
Expand Down Expand Up @@ -350,3 +351,20 @@ func runUploadProxyAgentCert(r workflow.RunData) error {
klog.V(2).InfoS("[Upload-ProxyAgentCert] Successfully uploaded virtual cluster agent certs to secret", "virtual cluster", klog.KObj(data))
return nil
}

func runCheckVirtualClusterAnp(r workflow.RunData) error {
data, ok := r.(InitData)
if !ok {
return errors.New("check-VirtualClusterAnp task invoked with an invalid data struct")
}

checker := apiclient.NewVirtualClusterChecker(data.RemoteClient(), constants.ComponentBeReadyTimeout)

err := checker.WaitForSomePods(virtualClusterAnpLabels.String(), data.GetNamespace(), 1)
if err != nil {
return fmt.Errorf("checking for virtual cluster anp to ready timeout, err: %w", err)
}

klog.V(2).InfoS("[check-VirtualClusterAPIServer] the virtual cluster anp is ready", "virtual cluster", klog.KObj(data))
return nil
}
1 change: 1 addition & 0 deletions pkg/kubenest/tasks/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
virtualClusterManagerLabels = labels.Set{"virtualCluster-app": constants.VirtualClusterScheduler}
virtualClusterApiserverLabels = labels.Set{"virtualCluster-app": constants.ApiServer}
virtualClusterEtcdLabels = labels.Set{"virtualCluster-app": constants.Etcd}
virtualClusterAnpLabels = labels.Set{"virtualCluster-anp": constants.ApiServerAnp}
)

func NewCheckApiserverHealthTask() workflow.Task {
Expand Down

0 comments on commit fd0b73c

Please sign in to comment.