-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add health check for namespace
- Loading branch information
1 parent
f6117cf
commit df8c662
Showing
5 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package health | ||
|
||
import ( | ||
"fmt" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
func getNamespaceHealth(obj *unstructured.Unstructured) (*HealthStatus, error) { | ||
var node v1.Namespace | ||
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &node); err != nil { | ||
return nil, fmt.Errorf("failed to convert unstructured Node to typed: %v", err) | ||
} | ||
|
||
if node.Status.Phase == v1.NamespaceActive { | ||
return &HealthStatus{ | ||
Status: HealthStatusHealthy, | ||
}, nil | ||
} | ||
|
||
return &HealthStatus{ | ||
Status: HealthStatusDeleting, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
creationTimestamp: '2024-02-10T10:27:15Z' | ||
labels: | ||
kubernetes.io/metadata.name: media | ||
kustomize.toolkit.fluxcd.io/name: flux-system | ||
kustomize.toolkit.fluxcd.io/namespace: flux-system | ||
kustomize.toolkit.fluxcd.io/prune: disabled | ||
name: media | ||
resourceVersion: '4518738' | ||
uid: c1b2dc7f-7070-4ee5-9ae0-e43df5523cd8 | ||
spec: | ||
finalizers: | ||
- kubernetes | ||
status: | ||
phase: Terminating |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
creationTimestamp: '2024-02-10T10:27:15Z' | ||
labels: | ||
kubernetes.io/metadata.name: media | ||
kustomize.toolkit.fluxcd.io/name: flux-system | ||
kustomize.toolkit.fluxcd.io/namespace: flux-system | ||
kustomize.toolkit.fluxcd.io/prune: disabled | ||
name: media | ||
resourceVersion: '4518738' | ||
uid: c1b2dc7f-7070-4ee5-9ae0-e43df5523cd8 | ||
spec: | ||
finalizers: | ||
- kubernetes | ||
status: | ||
phase: Active |