-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Helm chart #11
Add Helm chart #11
Conversation
Signed-off-by: d-kuro <[email protected]>
f6350f5
to
849dfbf
Compare
Signed-off-by: d-kuro <[email protected]>
Signed-off-by: d-kuro <[email protected]>
Signed-off-by: d-kuro <[email protected]>
containers: | ||
- name: manager | ||
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" | ||
{{- with .Values.image.pullPolicy }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when pullPolicy is not set? Is it always set?
If so, can we simplify this as below?
imagePullPolicy: {{ .Values.image.pullPolicy }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default is undefined and the imagePullPolicy field is not added if not specified.
accurate/charts/accurate/values.yaml
Line 10 in d5cdc02
pullPolicy: # Always |
I will explicitly set IfNotPresent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if pullPolicy is not set, this would render as follows, right?
spec:
containers:
- name: manager
image: ...
imagePullPolicy: # empty
I don't like this. Could you omit imagePullPolicy:
altogether when pullPolicy is not set?
Signed-off-by: d-kuro <[email protected]>
e6c44a4
to
f7890ab
Compare
Signed-off-by: d-kuro <[email protected]>
I fixed the pull request. Review Poinsts: |
name: {{ template "accurate.fullname" . }}-additional-resources | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "accurate.fullname" . }}-controller-manager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, users cannot stop creating a ServiceAccount, right?
containers: | ||
- name: manager | ||
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" | ||
{{- with .Values.image.pullPolicy }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if pullPolicy is not set, this would render as follows, right?
spec:
containers:
- name: manager
image: ...
imagePullPolicy: # empty
I don't like this. Could you omit imagePullPolicy:
altogether when pullPolicy is not set?
{{- with .Values.image.pullPolicy }} | ||
imagePullPolicy: {{ . }} | ||
{{- end }} | ||
{{- with .Values.controller.extraArgs }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it renders as follows, right?
args: # empty
Same above. Please fix.
Signed-off-by: d-kuro <[email protected]>
Signed-off-by: d-kuro <[email protected]>
Signed-off-by: d-kuro <[email protected]>
Signed-off-by: d-kuro <[email protected]>
Is there a case where a User wants to stop creating a ServiceAccount?
No, if the field is empty the Rendering with the default values will result in the following YAML:
<snip>
# Source: accurate/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: accurate-controller-manager
namespace: accurate
labels:
app.kubernetes.io/component: controller
helm.sh/chart: accurate-0.1.0
app.kubernetes.io/name: accurate
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/component: controller
template:
metadata:
annotations:
checksum/config: 856d9f37889d4ef4ad9a5bbec38b558ab0e1c5db0dac189d4e9aceadf52be133
labels:
app.kubernetes.io/component: controller
spec:
containers:
- name: manager
image: "ghcr.io/cybozu-go/accurate:0.1.0"
ports:
- containerPort: 9443
name: webhook-server
protocol: TCP
- containerPort: 8081
name: health
protocol: TCP
- containerPort: 8080
name: metrics
protocol: TCP
resources:
requests:
cpu: 100m
memory: 20Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
livenessProbe:
httpGet:
path: /healthz
port: health
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: health
initialDelaySeconds: 5
periodSeconds: 10
volumeMounts:
- mountPath: /tmp/k8s-webhook-server/serving-certs
name: cert
readOnly: true
- mountPath: /etc/accurate
name: config
securityContext:
runAsNonRoot: true
serviceAccountName: accurate-controller-manager
terminationGracePeriodSeconds: 10
volumes:
- name: cert
secret:
defaultMode: 420
secretName: webhook-server-cert
- configMap:
name: accurate-config
name: config
<snip> |
I don't think users want to avoid creating a ServiceAccount, but my point is that I'd like either one of the following:
I see. Thank you. |
I see, thank you for comments.
In the
This is no longer in use and has been removed in the following commit: So a ServiceAccount is always created. |
Great! |
Difference from kustomize
Test codes
package tests
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/d-kuro/helmut"
"github.com/d-kuro/helmut/assert"
"github.com/d-kuro/helmut/util"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
)
func TestHelmCharts(t *testing.T) {
bytes, err := os.ReadFile(filepath.Join("testdata", "kustomize.yaml"))
if err != nil {
t.Fatal(err)
}
const releaseName = "accurate"
r := helmut.New()
manifests, err := r.RenderTemplates(releaseName, filepath.Join("..", "accurate"), helmut.WithNamespace("accurate"), helmut.WithIncludeCRDs())
if err != nil {
t.Fatal(err)
}
splitManifests, err := util.SplitManifests(bytes)
if err != nil {
t.Fatal(err)
}
removeSiffux := func(key helmut.ObjectKey) helmut.ObjectKey {
if strings.HasPrefix(key.Name, "accurate-config") {
key.Name = "accurate-config"
return key
}
return key
}
for _, manifest := range splitManifests {
obj, _ := util.MustRawManifestToObject(clientgoscheme.Scheme, manifest)
key, err := helmut.NewObjectKeyFromObject(obj)
if err != nil {
t.Fatal(err)
}
t.Run(key.String(), func(t *testing.T) {
assert.Contains(t, manifests, obj, assert.WithAdditionalKeys(removeSiffux))
})
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
refs: #10
Review Points
TODOs
Diffs