Add namespace support to Kubernetes client (#1446)
* Add namespace support to Kubernetes client * Fix LastUpdateTime Condition
This commit is contained in:
parent
1222d076f2
commit
3d274ab6a2
@ -129,7 +129,7 @@ func (k *kubernetes) getService(labels map[string]string) ([]*service, error) {
|
|||||||
// parse out deployment status and inject into service metadata
|
// parse out deployment status and inject into service metadata
|
||||||
if len(kdep.Status.Conditions) > 0 {
|
if len(kdep.Status.Conditions) > 0 {
|
||||||
svc.Metadata["status"] = kdep.Status.Conditions[0].Type
|
svc.Metadata["status"] = kdep.Status.Conditions[0].Type
|
||||||
svc.Metadata["started"] = kdep.Status.Conditions[0].LastUpdate
|
svc.Metadata["started"] = kdep.Status.Conditions[0].LastUpdateTime
|
||||||
delete(svc.Metadata, "error")
|
delete(svc.Metadata, "error")
|
||||||
} else {
|
} else {
|
||||||
svc.Metadata["status"] = "n/a"
|
svc.Metadata["status"] = "n/a"
|
||||||
|
@ -3,6 +3,7 @@ package client
|
|||||||
var templates = map[string]string{
|
var templates = map[string]string{
|
||||||
"deployment": deploymentTmpl,
|
"deployment": deploymentTmpl,
|
||||||
"service": serviceTmpl,
|
"service": serviceTmpl,
|
||||||
|
"namespace": namespaceTmpl,
|
||||||
}
|
}
|
||||||
|
|
||||||
// stripped image pull policy always
|
// stripped image pull policy always
|
||||||
@ -108,3 +109,16 @@ spec:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var namespaceTmpl = `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: "{{ .Metadata.Name }}"
|
||||||
|
labels:
|
||||||
|
{{- with .Metadata.Labels }}
|
||||||
|
{{- range $key, $value := . }}
|
||||||
|
{{ $key }}: "{{ $value }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
`
|
||||||
|
@ -39,10 +39,10 @@ type DeploymentSpec struct {
|
|||||||
|
|
||||||
// DeploymentCondition describes the state of deployment
|
// DeploymentCondition describes the state of deployment
|
||||||
type DeploymentCondition struct {
|
type DeploymentCondition struct {
|
||||||
LastUpdate string `json:lastUpdateTime`
|
LastUpdateTime string `json:"lastUpdateTime"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
reason string `json:"reason,omitempty"`
|
Reason string `json:"reason,omitempty"`
|
||||||
message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeploymentStatus is returned when querying deployment
|
// DeploymentStatus is returned when querying deployment
|
||||||
@ -178,3 +178,8 @@ type Template struct {
|
|||||||
Metadata *Metadata `json:"metadata,omitempty"`
|
Metadata *Metadata `json:"metadata,omitempty"`
|
||||||
PodSpec *PodSpec `json:"spec,omitempty"`
|
PodSpec *PodSpec `json:"spec,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Namespace is a Kubernetes Namespace
|
||||||
|
type Namespace struct {
|
||||||
|
Metadata *Metadata `json:"metadata,omitempty"`
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user