Runtime: Add Kubernetes ServiceAccounts & Remove imagePullSecrets
This commit is contained in:
@@ -163,7 +163,7 @@ func (r *Request) request() (*http.Request, error) {
|
||||
case "namespace":
|
||||
// /api/v1/namespaces/
|
||||
url = fmt.Sprintf("%s/api/v1/namespaces/", r.host)
|
||||
case "pod", "service", "endpoint":
|
||||
case "pod", "service", "endpoint", "serviceaccount":
|
||||
// /api/v1/namespaces/{namespace}/pods
|
||||
url = fmt.Sprintf("%s/api/v1/namespaces/%s/%ss/", r.host, r.namespace, r.resource)
|
||||
case "deployment":
|
||||
|
@@ -312,6 +312,7 @@ func NewDeployment(name, version, typ, namespace string) *Deployment {
|
||||
Template: &Template{
|
||||
Metadata: Metadata,
|
||||
PodSpec: &PodSpec{
|
||||
ServiceAccountName: namespace,
|
||||
Containers: []Container{{
|
||||
Name: name,
|
||||
Image: DefaultImage,
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package client
|
||||
|
||||
var templates = map[string]string{
|
||||
"deployment": deploymentTmpl,
|
||||
"service": serviceTmpl,
|
||||
"namespace": namespaceTmpl,
|
||||
"deployment": deploymentTmpl,
|
||||
"service": serviceTmpl,
|
||||
"namespace": namespaceTmpl,
|
||||
"serviceaccount": serviceAccountTmpl,
|
||||
}
|
||||
|
||||
// stripped image pull policy always
|
||||
@@ -49,13 +50,8 @@ spec:
|
||||
{{ $key }}: "{{ $value }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
{{- with .Spec.Template.PodSpec.ImagePullSecrets }}
|
||||
{{- range . }}
|
||||
- name: "{{ .Name }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
serviceAccountName: {{ .Spec.Template.PodSpec.ServiceAccountName }}
|
||||
containers:
|
||||
{{- with .Spec.Template.PodSpec.Containers }}
|
||||
{{- range . }}
|
||||
@@ -128,3 +124,22 @@ metadata:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
`
|
||||
|
||||
var serviceAccountTmpl = `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: "{{ .Metadata.Name }}"
|
||||
labels:
|
||||
{{- with .Metadata.Labels }}
|
||||
{{- range $key, $value := . }}
|
||||
{{ $key }}: "{{ $value }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
imagePullSecrets:
|
||||
{{- with .ImagePullSecrets }}
|
||||
{{- range . }}
|
||||
- name: "{{ .Name }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
`
|
||||
|
@@ -93,8 +93,8 @@ type Metadata struct {
|
||||
|
||||
// PodSpec is a pod
|
||||
type PodSpec struct {
|
||||
Containers []Container `json:"containers"`
|
||||
ImagePullSecrets []ImagePullSecret `json:"imagePullSecrets"`
|
||||
Containers []Container `json:"containers"`
|
||||
ServiceAccountName string `json:"serviceAccountName"`
|
||||
}
|
||||
|
||||
// PodList
|
||||
@@ -194,3 +194,9 @@ type NamespaceList struct {
|
||||
type ImagePullSecret struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// ServiceAccount
|
||||
type ServiceAccount struct {
|
||||
Metadata *Metadata `json:"metadata,omitempty"`
|
||||
ImagePullSecrets []ImagePullSecret `json:"imagePullSecrets,omitempty"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user