kubernetes: fixes for production (#1812)

* util/kubernetes/client: add secrets to deployments

* util/kubernetes/client: remove ServiceAccountName override

* debugging

* runtime/kubernetes: fix error

* runtime/kubernetes: remove test secret

* util/kubernetes/client: update default image

* util/kubernetes/client: remove default command for deployments

* runtime/kubernetes: pass source as arg

* runtime/kubernetes: remove debugging

* util/kubernetes/client: revert default image change
This commit is contained in:
ben-toogood 2020-07-09 16:29:01 +01:00 committed by GitHub
parent 58d6726380
commit 6d9a38a747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 5 deletions

View File

@ -341,7 +341,7 @@ func (k *kubernetes) Logs(s *runtime.Service, options ...runtime.LogsOption) (ru
go func() {
records, err := klo.Read()
if err != nil {
log.Errorf("Failed to get logs for service '%v' from k8s: %v", err)
log.Errorf("Failed to get logs for service '%v' from k8s: %v", s.Name, err)
return
}
// @todo: this might actually not run before podLogStream starts

View File

@ -66,6 +66,9 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service {
kdeploy.Spec.Template.PodSpec.Containers[i].Command = []string{}
kdeploy.Spec.Template.PodSpec.Containers[i].Args = []string{}
}
} else {
// use the default image (micro/cell:go), passing the source as the first argument
kdeploy.Spec.Template.PodSpec.Containers[0].Args = []string{s.Source}
}
// define the environment values used by the container

View File

@ -312,12 +312,11 @@ func NewDeployment(name, version, typ, namespace string) *Deployment {
Template: &Template{
Metadata: Metadata,
PodSpec: &PodSpec{
ServiceAccountName: namespace,
Containers: []Container{{
Name: name,
Image: DefaultImage,
Env: []EnvVar{env},
Command: []string{"go", "run", "."},
Command: []string{},
Ports: []ContainerPort{{
Name: "service-port",
ContainerPort: 8080,

View File

@ -62,6 +62,19 @@ spec:
{{- range . }}
- name: "{{ .Name }}"
value: "{{ .Value }}"
{{- if .ValueFrom }}
{{- with .ValueFrom }}
valueFrom:
{{- if .SecretKeyRef }}
{{- with .SecretKeyRef }}
secretKeyRef:
key: {{ .Key }}
name: {{ .Name }}
optional: {{ .Optional }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
args:

View File

@ -10,8 +10,21 @@ type ContainerPort struct {
// EnvVar is environment variable
type EnvVar struct {
Name string `json:"name"`
Value string `json:"value,omitempty"`
Name string `json:"name"`
Value string `json:"value,omitempty"`
ValueFrom *EnvVarSource `json:"valueFrom,omitempty"`
}
// EnvVarSource represents a source for the value of an EnvVar.
type EnvVarSource struct {
SecretKeyRef *SecretKeySelector `json:"secretKeyRef,omitempty"`
}
// SecretKeySelector selects a key of a Secret.
type SecretKeySelector struct {
Key string `json:"key"`
Name string `json:"name"`
Optional bool `json:"optional,omitempty"`
}
type Condition struct {