Skip to content

Commit da7f566

Browse files
add support for limiting the transient storage (#86)
* add support for limiting the transient storage * Update cmd/kube-httpcache/internal/flags.go Co-authored-by: Martin Helmich <kontakt@martin-helmich.de> Co-authored-by: Martin Helmich <m.helmich@mittwald.de>
1 parent 2265347 commit da7f566

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

chart/templates/deployment.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ spec:
7171
- -varnish-secret-file=/etc/varnish/k8s-secret/secret
7272
- -varnish-vcl-template=/etc/varnish/tmpl/default.vcl.tmpl
7373
- -varnish-storage={{ .Values.cache.varnishStorage }},{{ .Values.cache.storageSize }}
74+
{{- if .Values.cache.varnishTransientStorage }}
75+
- -varnish-transient-storage={{ .Values.cache.varnishTransientStorage }},{{ .Values.cache.transientStorageSize }}
76+
{{- end }}
7477
{{- if .Values.cacheExtraArgs }}
7578
{{- with .Values.cacheExtraArgs }}
7679
{{- tpl . $ | trim | nindent 10 }}

chart/values.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ cache:
3838
varnishStorage: malloc # default,malloc,umem,file...
3939
# Varnish storage backend size
4040
storageSize: 128M # K(ibibytes), M(ebibytes), G(ibibytes), T(ebibytes) ... unlimited
41+
# Varnish transient storage backend type (https://varnish-cache.org/docs/trunk/users-guide/storage-backends.html)
42+
#varnishTransientStorage: malloc
43+
# Varnish transient storage backend size
44+
#transientStorageSize: 128M # K(ibibytes), M(ebibytes), G(ibibytes), T(ebibytes) ... unlimited
4145
# Secret for Varnish admin credentials
4246
#secret: "12345678"
4347
# Read admin credentials from user provided secret

cmd/kube-httpcache/internal/flags.go

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type KubeHTTPProxyFlags struct {
4545
Varnish struct {
4646
SecretFile string
4747
Storage string
48+
TransientStorage string
4849
AdditionalParameters string
4950
VCLTemplate string
5051
VCLTemplatePoll bool
@@ -89,6 +90,7 @@ func (f *KubeHTTPProxyFlags) Parse() error {
8990

9091
flag.StringVar(&f.Varnish.SecretFile, "varnish-secret-file", "/etc/varnish/secret", "Varnish secret file")
9192
flag.StringVar(&f.Varnish.Storage, "varnish-storage", "file,/tmp/varnish-data,1G", "varnish storage config")
93+
flag.StringVar(&f.Varnish.TransientStorage, "varnish-transient-storage", "malloc,128m", "varnish transient storage config")
9294
flag.StringVar(&f.Varnish.VCLTemplate, "varnish-vcl-template", "/etc/varnish/default.vcl.tmpl", "VCL template file")
9395
flag.StringVar(&f.Varnish.AdditionalParameters, "varnish-additional-parameters", "", "Additional Varnish start parameters (-p, seperated by comma), like 'ban_dups=on,cli_timeout=30'")
9496
flag.BoolVar(&f.Varnish.VCLTemplatePoll, "varnish-vcl-template-poll", false, "poll for file changes instead of using inotify (useful on some network filesystems)")

cmd/kube-httpcache/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func main() {
116116
varnishController, err := controller.NewVarnishController(
117117
opts.Varnish.SecretFile,
118118
opts.Varnish.Storage,
119+
opts.Varnish.TransientStorage,
119120
opts.Varnish.AdditionalParameters,
120121
opts.Varnish.WorkingDir,
121122
opts.Frontend.Address,

pkg/controller/run.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ func (v *VarnishController) generateArgs() []string {
8484
"-F",
8585
"-f", v.configFile,
8686
"-S", v.SecretFile,
87-
"-s", v.Storage,
87+
"-s", fmt.Sprintf("Cache=%s", v.Storage),
88+
"-s", fmt.Sprintf("Transient=%s", v.TransientStorage),
8889
"-a", fmt.Sprintf("%s:%d", v.FrontendAddr, v.FrontendPort),
8990
"-T", fmt.Sprintf("%s:%d", v.AdminAddr, v.AdminPort),
9091
}

pkg/controller/types.go

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type TemplateData struct {
2222
type VarnishController struct {
2323
SecretFile string
2424
Storage string
25+
TransientStorage string
2526
AdditionalParameters string
2627
WorkingDir string
2728
FrontendAddr string
@@ -45,6 +46,7 @@ type VarnishController struct {
4546
func NewVarnishController(
4647
secretFile string,
4748
storage string,
49+
transientStorage string,
4850
additionalParameter string,
4951
workingDir string,
5052
frontendAddr string,
@@ -75,6 +77,7 @@ func NewVarnishController(
7577
return &VarnishController{
7678
SecretFile: secretFile,
7779
Storage: storage,
80+
TransientStorage: transientStorage,
7881
AdditionalParameters: additionalParameter,
7982
WorkingDir: workingDir,
8083
FrontendAddr: frontendAddr,

0 commit comments

Comments
 (0)