Skip to content

Commit

Permalink
✨ Update service account
Browse files Browse the repository at this point in the history
  • Loading branch information
tosone committed Sep 17, 2024
1 parent b52920e commit 19e8c84
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
7 changes: 7 additions & 0 deletions deploy/sigma/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ data:
server: 0.0.0.0:{{.Values.service.server.port}}
worker: 0.0.0.0:{{.Values.service.worker.port}}
daemon:
builder:
enabled: true
image: "{{ .Values.image.registry }}/{{ .Values.config.daemon.builder.image.repository }}:{{ .Values.config.daemon.builder.image.tag | default .Chart.AppVersion }}"
type: kubernetes
kubernetes:
kubeconfig: ""
namespace: default
gc:
# if blob not associate with artifact
retention: 72h
Expand Down
24 changes: 6 additions & 18 deletions deploy/sigma/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ metadata:
{{- end }}
rules:
- apiGroups:
- ""
- core
resources:
- configmaps
- pods
verbs:
- get
- list
Expand All @@ -24,31 +24,19 @@ rules:
- patch
- delete
- apiGroups:
- ""
- core
resources:
- configmaps/status
- pods/status
verbs:
- get
- update
- patch
- apiGroups:
- ""
- core
resources:
- events
- pods/finalizers
verbs:
- create
- apiGroups:
- "coordination.k8s.io"
resources:
- leases
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
---
kind: RoleBinding
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
Expand Down
13 changes: 11 additions & 2 deletions deploy/sigma/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ serviceAccount:
## @param serviceAccount.annotations Additional Service Account annotations (evaluated as a template)
annotations: {}
## @param serviceAccount.automountServiceAccountToken Automount service account token for the server service account
automountServiceAccountToken: false
automountServiceAccountToken: true

config:
log:
Expand All @@ -121,7 +121,16 @@ config:
type: s3
filesystem:
path: /
# Notice: the tag never update after the first pulled from remote registry, unless you delete the image and pull again.
daemon:
builder:
enabled: false
image:
repository: tosone/sigma-builder
tag: latest
type: docker
kubernetes:
kubeconfig: ""
namespace: default
proxy:
enabled: true
endpoint: https://registry-1.docker.io
Expand Down
5 changes: 3 additions & 2 deletions pkg/builder/kubernetes/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"path"
"reflect"
"strconv"
"strings"

"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -50,7 +51,7 @@ func (f factory) New(config configs.Configuration) (builder.Builder, error) {

var err error
var restConfig *restclient.Config
if config.Daemon.Builder.Kubernetes.Kubeconfig != nil {
if strings.TrimSpace(ptr.To(config.Daemon.Builder.Kubernetes.Kubeconfig)) != "" {

Check warning on line 54 in pkg/builder/kubernetes/k8s.go

View check run for this annotation

Codecov / codecov/patch

pkg/builder/kubernetes/k8s.go#L54

Added line #L54 was not covered by tests
cfg := clientcmdapi.NewConfig()
err := yaml.Unmarshal([]byte(ptr.To(config.Daemon.Builder.Kubernetes.Kubeconfig)), &cfg)
if err != nil {
Expand All @@ -62,7 +63,7 @@ func (f factory) New(config configs.Configuration) (builder.Builder, error) {
return nil, fmt.Errorf("Get k8s rest config failed: %v", err)
}
} else {
restConfig, err = clientcmd.BuildConfigFromFlags("", "")
restConfig, err = restclient.InClusterConfig()

Check warning on line 66 in pkg/builder/kubernetes/k8s.go

View check run for this annotation

Codecov / codecov/patch

pkg/builder/kubernetes/k8s.go#L66

Added line #L66 was not covered by tests
if err != nil {
return nil, fmt.Errorf("Get k8s client in cluster failed: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/inits/baseimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func init() {
const baseImageDir = "./bin"

func initBaseimage(config configs.Configuration) error {
if !config.Daemon.Builder.Enabled {
if config.Daemon.Builder.Enabled {

Check warning on line 47 in pkg/inits/baseimage.go

View check run for this annotation

Codecov / codecov/patch

pkg/inits/baseimage.go#L47

Added line #L47 was not covered by tests
return nil
}
dir := strings.TrimPrefix(baseImageDir, "./")
Expand Down

0 comments on commit 19e8c84

Please sign in to comment.