Svc metadata (#972)
* Added service metadata * Added metadata to runtime service * Add Annotations metadata to service metadata * Add micro/micro as default service owners * Update runtime/kubernetes/client/kubernetes.go Change comment Co-Authored-By: Jake Sanders <i@am.so-aweso.me>
This commit is contained in:
@@ -152,10 +152,5 @@ func (c *client) List(r *Resource) error {
|
||||
"micro": "service",
|
||||
}
|
||||
|
||||
return api.NewRequest(c.opts).
|
||||
Get().
|
||||
Resource(r.Kind).
|
||||
Params(&api.Params{LabelSelector: labels}).
|
||||
Do().
|
||||
Into(r.Value)
|
||||
return c.Get(r, labels)
|
||||
}
|
||||
|
@@ -50,7 +50,6 @@ func DefaultService(name, version string) *Service {
|
||||
if len(version) > 0 {
|
||||
// API service object name joins name and version over "-"
|
||||
svcName = strings.Join([]string{name, version}, "-")
|
||||
|
||||
}
|
||||
|
||||
Metadata := &Metadata{
|
||||
@@ -84,26 +83,32 @@ func DefaultDeployment(name, version, source string) *Deployment {
|
||||
"micro": "service",
|
||||
}
|
||||
|
||||
// API deployment object name joins name and version over "="
|
||||
depName := strings.Join([]string{name, version}, "-")
|
||||
depName := name
|
||||
if len(version) > 0 {
|
||||
// API deployment object name joins name and version over "-"
|
||||
depName = strings.Join([]string{name, version}, "-")
|
||||
}
|
||||
|
||||
Metadata := &Metadata{
|
||||
Name: depName,
|
||||
Namespace: "default",
|
||||
Version: version,
|
||||
Labels: Labels,
|
||||
Annotations: map[string]string{
|
||||
"source": source,
|
||||
"owner": "micro",
|
||||
"group": "micro",
|
||||
},
|
||||
}
|
||||
|
||||
// TODO: we need to figure out this version stuff
|
||||
// might be worth adding Build to runtime.Service
|
||||
// might have to add Build to runtime.Service
|
||||
buildTime, err := strconv.ParseInt(version, 10, 64)
|
||||
if err == nil {
|
||||
buildUnixTimeUTC := time.Unix(buildTime, 0)
|
||||
Metadata.Annotations = map[string]string{
|
||||
"build": buildUnixTimeUTC.Format(time.RFC3339),
|
||||
}
|
||||
Metadata.Annotations["build"] = buildUnixTimeUTC.Format(time.RFC3339)
|
||||
} else {
|
||||
log.Debugf("Runtime could not parse build: %v", err)
|
||||
log.Debugf("could not parse build: %v", err)
|
||||
}
|
||||
|
||||
// enable go modules by default
|
||||
|
@@ -17,6 +17,12 @@ metadata:
|
||||
{{ $key }}: "{{ $value }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- with .Metadata.Annotations }}
|
||||
{{- range $key, $value := . }}
|
||||
{{ $key }}: "{{ $value }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
replicas: {{ .Spec.Replicas }}
|
||||
selector:
|
||||
|
@@ -103,13 +103,21 @@ type DeploymentSpec struct {
|
||||
Template *Template `json:"template,omitempty"`
|
||||
}
|
||||
|
||||
// DeploymentCondition describes the state of deployment
|
||||
type DeploymentCondition struct {
|
||||
Type string `json:"type"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// DeploymentStatus is returned when querying deployment
|
||||
type DeploymentStatus struct {
|
||||
Replicas int `json:"replicas,omitempty"`
|
||||
UpdatedReplicas int `json:"updatedReplicas,omitempty"`
|
||||
ReadyReplicas int `json:"readyReplicas,omitempty"`
|
||||
AvailableReplicas int `json:"availableReplicas,omitempty"`
|
||||
UnavailableReplicas int `json:"unavailableReplicas,omitempty"`
|
||||
Replicas int `json:"replicas,omitempty"`
|
||||
UpdatedReplicas int `json:"updatedReplicas,omitempty"`
|
||||
ReadyReplicas int `json:"readyReplicas,omitempty"`
|
||||
AvailableReplicas int `json:"availableReplicas,omitempty"`
|
||||
UnavailableReplicas int `json:"unavailableReplicas,omitempty"`
|
||||
Conditions []DeploymentCondition `json:"conditions,omitempty"`
|
||||
}
|
||||
|
||||
// Deployment is Kubernetes deployment
|
||||
|
Reference in New Issue
Block a user