Skip to content

Commit

Permalink
add support for limiting the transient storage (#86)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people committed Aug 25, 2021
1 parent 2265347 commit da7f566
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ spec:
- -varnish-secret-file=/etc/varnish/k8s-secret/secret
- -varnish-vcl-template=/etc/varnish/tmpl/default.vcl.tmpl
- -varnish-storage={{ .Values.cache.varnishStorage }},{{ .Values.cache.storageSize }}
{{- if .Values.cache.varnishTransientStorage }}
- -varnish-transient-storage={{ .Values.cache.varnishTransientStorage }},{{ .Values.cache.transientStorageSize }}
{{- end }}
{{- if .Values.cacheExtraArgs }}
{{- with .Values.cacheExtraArgs }}
{{- tpl . $ | trim | nindent 10 }}
Expand Down
4 changes: 4 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ cache:
varnishStorage: malloc # default,malloc,umem,file...
# Varnish storage backend size
storageSize: 128M # K(ibibytes), M(ebibytes), G(ibibytes), T(ebibytes) ... unlimited
# Varnish transient storage backend type (https://varnish-cache.org/docs/trunk/users-guide/storage-backends.html)
#varnishTransientStorage: malloc
# Varnish transient storage backend size
#transientStorageSize: 128M # K(ibibytes), M(ebibytes), G(ibibytes), T(ebibytes) ... unlimited
# Secret for Varnish admin credentials
#secret: "12345678"
# Read admin credentials from user provided secret
Expand Down
2 changes: 2 additions & 0 deletions cmd/kube-httpcache/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type KubeHTTPProxyFlags struct {
Varnish struct {
SecretFile string
Storage string
TransientStorage string
AdditionalParameters string
VCLTemplate string
VCLTemplatePoll bool
Expand Down Expand Up @@ -89,6 +90,7 @@ func (f *KubeHTTPProxyFlags) Parse() error {

flag.StringVar(&f.Varnish.SecretFile, "varnish-secret-file", "/etc/varnish/secret", "Varnish secret file")
flag.StringVar(&f.Varnish.Storage, "varnish-storage", "file,/tmp/varnish-data,1G", "varnish storage config")
flag.StringVar(&f.Varnish.TransientStorage, "varnish-transient-storage", "malloc,128m", "varnish transient storage config")
flag.StringVar(&f.Varnish.VCLTemplate, "varnish-vcl-template", "/etc/varnish/default.vcl.tmpl", "VCL template file")
flag.StringVar(&f.Varnish.AdditionalParameters, "varnish-additional-parameters", "", "Additional Varnish start parameters (-p, seperated by comma), like 'ban_dups=on,cli_timeout=30'")
flag.BoolVar(&f.Varnish.VCLTemplatePoll, "varnish-vcl-template-poll", false, "poll for file changes instead of using inotify (useful on some network filesystems)")
Expand Down
1 change: 1 addition & 0 deletions cmd/kube-httpcache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func main() {
varnishController, err := controller.NewVarnishController(
opts.Varnish.SecretFile,
opts.Varnish.Storage,
opts.Varnish.TransientStorage,
opts.Varnish.AdditionalParameters,
opts.Varnish.WorkingDir,
opts.Frontend.Address,
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func (v *VarnishController) generateArgs() []string {
"-F",
"-f", v.configFile,
"-S", v.SecretFile,
"-s", v.Storage,
"-s", fmt.Sprintf("Cache=%s", v.Storage),
"-s", fmt.Sprintf("Transient=%s", v.TransientStorage),
"-a", fmt.Sprintf("%s:%d", v.FrontendAddr, v.FrontendPort),
"-T", fmt.Sprintf("%s:%d", v.AdminAddr, v.AdminPort),
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type TemplateData struct {
type VarnishController struct {
SecretFile string
Storage string
TransientStorage string
AdditionalParameters string
WorkingDir string
FrontendAddr string
Expand All @@ -45,6 +46,7 @@ type VarnishController struct {
func NewVarnishController(
secretFile string,
storage string,
transientStorage string,
additionalParameter string,
workingDir string,
frontendAddr string,
Expand Down Expand Up @@ -75,6 +77,7 @@ func NewVarnishController(
return &VarnishController{
SecretFile: secretFile,
Storage: storage,
TransientStorage: transientStorage,
AdditionalParameters: additionalParameter,
WorkingDir: workingDir,
FrontendAddr: frontendAddr,
Expand Down

0 comments on commit da7f566

Please sign in to comment.