Skip to content

Commit

Permalink
Merge pull request #5775 from jabellard/api_server_service_info2
Browse files Browse the repository at this point in the history
Add API Server Service Information to `KarmadaStatus`
  • Loading branch information
karmada-bot authored Nov 4, 2024
2 parents 3ccd0fe + 325e3bd commit 01b8312
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
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

0 comments on commit 01b8312

Please sign in to comment.