Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API Server Service Information to KarmadaStatus #5775

Merged
merged 1 commit into from
Nov 4, 2024
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
13 changes: 13 additions & 0 deletions charts/karmada-operator/crds/operator.karmada.io_karmadas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3724,6 +3724,19 @@ spec:
status:
description: Most recently observed status of the Karmada.
properties:
apiServerService:
description: |-
APIServerService reports the location of the Karmada API server service which
can be used by third-party applications to discover the Karmada Service, e.g.
expose the service outside the cluster by Ingress.
properties:
name:
description: Name represents the name of the Karmada API Server
service.
type: string
required:
- name
type: object
conditions:
description: Conditions represents the latest available observations
of a karmada's current state.
Expand Down
13 changes: 13 additions & 0 deletions operator/config/crds/operator.karmada.io_karmadas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3724,6 +3724,19 @@ spec:
status:
description: Most recently observed status of the Karmada.
properties:
apiServerService:
description: |-
APIServerService reports the location of the Karmada API server service which
can be used by third-party applications to discover the Karmada Service, e.g.
expose the service outside the cluster by Ingress.
properties:
name:
description: Name represents the name of the Karmada API Server
service.
type: string
required:
- name
type: object
conditions:
description: Conditions represents the latest available observations
of a karmada's current state.
Expand Down
15 changes: 15 additions & 0 deletions operator/pkg/apis/operator/v1alpha1/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,21 @@ type KarmadaStatus struct {
// Conditions represents the latest available observations of a karmada's current state.
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// APIServerService reports the location of the Karmada API server service which
// can be used by third-party applications to discover the Karmada Service, e.g.
// expose the service outside the cluster by Ingress.
// +optional
APIServerService *APIServerService `json:"apiServerService,omitempty"`
}

// APIServerService tells the location of Karmada API server service.
// Currently, it only includes the name of the service. The namespace
// of the service is the same as the namespace of the current Karmada object.
type APIServerService struct {
// Name represents the name of the Karmada API Server service.
// +required
Name string `json:"name"`
}

// LocalSecretReference is a reference to a secret within the enclosing
Expand Down
21 changes: 21 additions & 0 deletions operator/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions operator/pkg/controller/karmada/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ func (p *Planner) afterRunJob() error {
Namespace: p.karmada.GetNamespace(),
Name: util.AdminKubeconfigSecretName(p.karmada.GetName()),
}
p.karmada.Status.APIServerService = &operatorv1alpha1.APIServerService{
Name: util.KarmadaAPIServerName(p.karmada.GetName()),
}
return p.Client.Status().Update(context.TODO(), p.karmada)
}
// if it is deInit workflow, the cr will be deleted with karmada is be deleted, so we need not to
Expand Down
7 changes: 7 additions & 0 deletions operator/pkg/controller/karmada/planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ func TestAfterRunJob(t *testing.T) {
if err := verifyJobInCommon(planner, metav1.ConditionTrue, conditionMsg, "Completed"); err != nil {
return fmt.Errorf("failed to verify after run job, got error: %v", err)
}
if planner.karmada.Status.APIServerService == nil {
return fmt.Errorf("expected API Server service ref to be set, but got nil")
}
expectedAPIServerName := util.KarmadaAPIServerName(karmada.GetName())
if planner.karmada.Status.APIServerService.Name != expectedAPIServerName {
return fmt.Errorf("expected API Server service Name to be %s, but got %s", expectedAPIServerName, planner.karmada.Status.APIServerService.Name)
}

return nil
},
Expand Down