1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

Runtime: Add Kubernetes ServiceAccounts & Remove imagePullSecrets

This commit is contained in:
Ben Toogood 2020-04-27 14:13:51 +01:00
parent 434997e676
commit 494e0b5060
9 changed files with 84 additions and 91 deletions

View File

@ -38,12 +38,6 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service {
kdeploy.Spec.Template.Metadata.Annotations = make(map[string]string) kdeploy.Spec.Template.Metadata.Annotations = make(map[string]string)
} }
// set the image pull secrets
kdeploy.Spec.Template.PodSpec.ImagePullSecrets = make([]client.ImagePullSecret, len(c.ImagePullSecrets))
for i, s := range c.ImagePullSecrets {
kdeploy.Spec.Template.PodSpec.ImagePullSecrets[i] = client.ImagePullSecret{Name: s}
}
// create if non existent // create if non existent
if s.Metadata == nil { if s.Metadata == nil {
s.Metadata = make(map[string]string) s.Metadata = make(map[string]string)

View File

@ -67,8 +67,6 @@ type CreateOptions struct {
Retries int Retries int
// Specify the image to use // Specify the image to use
Image string Image string
// Specify secrets to use when pulling the image
ImagePullSecrets []string
// Namespace to create the service in // Namespace to create the service in
Namespace string Namespace string
// Specify the context to use // Specify the context to use
@ -103,13 +101,6 @@ func CreateImage(img string) CreateOption {
} }
} }
// CreateImagePullSecret sets a secret to use
func CreateImagePullSecret(secrets ...string) CreateOption {
return func(o *CreateOptions) {
o.ImagePullSecrets = append(o.ImagePullSecrets, secrets...)
}
}
// CreateNamespace sets the namespace // CreateNamespace sets the namespace
func CreateNamespace(ns string) CreateOption { func CreateNamespace(ns string) CreateOption {
return func(o *CreateOptions) { return func(o *CreateOptions) {

View File

@ -162,9 +162,7 @@ type CreateOptions struct {
// create type of service // create type of service
Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"`
// image to use // image to use
Image string `protobuf:"bytes,6,opt,name=image,proto3" json:"image,omitempty"` Image string `protobuf:"bytes,6,opt,name=image,proto3" json:"image,omitempty"`
// image secrets to use
ImagePullSecrets []string `protobuf:"bytes,7,rep,name=image_pull_secrets,json=imagePullSecrets,proto3" json:"image_pull_secrets,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -237,13 +235,6 @@ func (m *CreateOptions) GetImage() string {
return "" return ""
} }
func (m *CreateOptions) GetImagePullSecrets() []string {
if m != nil {
return m.ImagePullSecrets
}
return nil
}
type CreateRequest struct { type CreateRequest struct {
Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
Options *CreateOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` Options *CreateOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"`
@ -821,49 +812,47 @@ func init() {
} }
var fileDescriptor_976fccef828ab1f0 = []byte{ var fileDescriptor_976fccef828ab1f0 = []byte{
// 689 bytes of a gzipped FileDescriptorProto // 662 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4b, 0x6f, 0xd3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xbb, 0x6e, 0xdb, 0x4a,
0x10, 0xae, 0xe3, 0x3c, 0xda, 0x09, 0x41, 0xd1, 0xaa, 0x42, 0xa6, 0xbc, 0x22, 0x5f, 0x28, 0x12, 0x10, 0x35, 0x45, 0x3d, 0xec, 0xd1, 0xd5, 0x85, 0xb1, 0x30, 0x02, 0xc6, 0x79, 0x09, 0x6c, 0xe2,
0x38, 0x28, 0x15, 0xe2, 0x25, 0x4e, 0x6d, 0xca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d, 0xeb, 0x50, 0x42,
0xa1, 0x6b, 0x1e, 0x10, 0x69, 0x7c, 0x74, 0x56, 0xde, 0x83, 0x51, 0x73, 0x82, 0xed, 0xf2, 0x0e, 0x3d, 0xef, 0xfa, 0xb9, 0x02, 0xba, 0x82, 0xa1, 0x19, 0xcd, 0x36, 0x5e, 0x8d, 0xd1, 0x6f, 0xe3,
0xf9, 0x0a, 0x6d, 0x35, 0xde, 0xa4, 0xe1, 0x39, 0x94, 0xa5, 0x9e, 0x37, 0x7d, 0xae, 0x0a, 0x9d, 0xb5, 0x31, 0xd5, 0x1a, 0xce, 0x4c, 0x64, 0x1b, 0x5c, 0x63, 0xe2, 0xdb, 0xe0, 0x36, 0x86, 0x79,
0x43, 0xd7, 0x8c, 0xe6, 0x26, 0x5c, 0x2b, 0xa3, 0xbf, 0x09, 0xd7, 0xda, 0x54, 0xeb, 0x72, 0x66, 0x8f, 0x5c, 0x40, 0x5f, 0x0d, 0x5e, 0x9b, 0xcc, 0xda, 0x40, 0x1e, 0x3f, 0x79, 0xa0, 0xe9, 0xfe,
0x22, 0x37, 0x95, 0x5b, 0x99, 0xf8, 0x4d, 0xe5, 0xd6, 0x86, 0x79, 0x87, 0x9c, 0x42, 0x5b, 0x0d, 0xde, 0x1b, 0xe7, 0x66, 0xa8, 0xff, 0x2f, 0x4f, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x40, 0x42,
0xde, 0x26, 0x9a, 0xb5, 0x81, 0x3c, 0x78, 0x72, 0x4f, 0xd3, 0xfd, 0x9d, 0xb7, 0xce, 0x75, 0x57, 0xb3, 0x4e, 0x70, 0x07, 0x00, 0x00,
0xff, 0x5d, 0x8f, 0xfe, 0x07, 0x00, 0x00, 0xff, 0xff, 0x4c, 0x31, 0x4d, 0x46, 0x9e, 0x07, 0x00,
0x00,
} }

View File

@ -41,8 +41,6 @@ message CreateOptions {
string type = 5; string type = 5;
// image to use // image to use
string image = 6; string image = 6;
// image secrets to use
repeated string image_pull_secrets = 7;
} }
message CreateRequest { message CreateRequest {

View File

@ -52,12 +52,11 @@ func (s *svc) Create(svc *runtime.Service, opts ...runtime.CreateOption) error {
Metadata: svc.Metadata, Metadata: svc.Metadata,
}, },
Options: &pb.CreateOptions{ Options: &pb.CreateOptions{
Command: options.Command, Command: options.Command,
Args: options.Args, Args: options.Args,
Env: options.Env, Env: options.Env,
Type: options.Type, Type: options.Type,
Image: options.Image, Image: options.Image,
ImagePullSecrets: options.ImagePullSecrets,
}, },
} }

View File

@ -163,7 +163,7 @@ func (r *Request) request() (*http.Request, error) {
case "namespace": case "namespace":
// /api/v1/namespaces/ // /api/v1/namespaces/
url = fmt.Sprintf("%s/api/v1/namespaces/", r.host) url = fmt.Sprintf("%s/api/v1/namespaces/", r.host)
case "pod", "service", "endpoint": case "pod", "service", "endpoint", "serviceaccount":
// /api/v1/namespaces/{namespace}/pods // /api/v1/namespaces/{namespace}/pods
url = fmt.Sprintf("%s/api/v1/namespaces/%s/%ss/", r.host, r.namespace, r.resource) url = fmt.Sprintf("%s/api/v1/namespaces/%s/%ss/", r.host, r.namespace, r.resource)
case "deployment": case "deployment":

View File

@ -312,6 +312,7 @@ func NewDeployment(name, version, typ, namespace string) *Deployment {
Template: &Template{ Template: &Template{
Metadata: Metadata, Metadata: Metadata,
PodSpec: &PodSpec{ PodSpec: &PodSpec{
ServiceAccountName: namespace,
Containers: []Container{{ Containers: []Container{{
Name: name, Name: name,
Image: DefaultImage, Image: DefaultImage,

View File

@ -1,9 +1,10 @@
package client package client
var templates = map[string]string{ var templates = map[string]string{
"deployment": deploymentTmpl, "deployment": deploymentTmpl,
"service": serviceTmpl, "service": serviceTmpl,
"namespace": namespaceTmpl, "namespace": namespaceTmpl,
"serviceaccount": serviceAccountTmpl,
} }
// stripped image pull policy always // stripped image pull policy always
@ -49,13 +50,8 @@ spec:
{{ $key }}: "{{ $value }}" {{ $key }}: "{{ $value }}"
{{- end }} {{- end }}
{{- end }} {{- end }}
spec: spec:
imagePullSecrets: serviceAccountName: {{ .Spec.Template.PodSpec.ServiceAccountName }}
{{- with .Spec.Template.PodSpec.ImagePullSecrets }}
{{- range . }}
- name: "{{ .Name }}"
{{- end }}
{{- end }}
containers: containers:
{{- with .Spec.Template.PodSpec.Containers }} {{- with .Spec.Template.PodSpec.Containers }}
{{- range . }} {{- range . }}
@ -128,3 +124,22 @@ metadata:
{{- end }} {{- end }}
{{- 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 }}
`

View File

@ -93,8 +93,8 @@ type Metadata struct {
// PodSpec is a pod // PodSpec is a pod
type PodSpec struct { type PodSpec struct {
Containers []Container `json:"containers"` Containers []Container `json:"containers"`
ImagePullSecrets []ImagePullSecret `json:"imagePullSecrets"` ServiceAccountName string `json:"serviceAccountName"`
} }
// PodList // PodList
@ -194,3 +194,9 @@ type NamespaceList struct {
type ImagePullSecret struct { type ImagePullSecret struct {
Name string `json:"name"` Name string `json:"name"`
} }
// ServiceAccount
type ServiceAccount struct {
Metadata *Metadata `json:"metadata,omitempty"`
ImagePullSecrets []ImagePullSecret `json:"imagePullSecrets,omitempty"`
}