Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Use ClusterIP service name for connecting to memcached #1618

Merged
merged 4 commits into from
Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions chart/flux/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ spec:
- --ssh-keygen-dir=/var/fluxd/keygen
- --k8s-secret-name={{ template "flux.fullname" . }}-git-deploy
- --memcached-hostname={{ template "flux.fullname" . }}-memcached
{{- if .Values.memcached.createClusterIP }}
- --memcached-service=
{{- end }}
- --git-url={{ .Values.git.url }}
- --git-branch={{ .Values.git.branch }}
- --git-path={{ .Values.git.path }}
Expand Down
2 changes: 2 additions & 0 deletions chart/flux/templates/memcached.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
{{- if eq .Values.memcached.createClusterIP false }}
clusterIP: None
{{- end }}
ports:
- port: 11211
targetPort: memcached
Expand Down
1 change: 1 addition & 0 deletions chart/flux/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ registry:
memcached:
repository: memcached
tag: 1.4.25
createClusterIP: true
verbose: false
maxItemSize: 1m
maxMemory: 64
Expand Down
14 changes: 12 additions & 2 deletions cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,24 @@ func main() {
{
// Cache client, for use by registry and cache warmer
var cacheClient cache.Client
memcacheClient := registryMemcache.NewMemcacheClient(registryMemcache.MemcacheConfig{
var memcacheClient *registryMemcache.MemcacheClient
memcacheConfig := registryMemcache.MemcacheConfig{
Host: *memcachedHostname,
Service: *memcachedService,
Timeout: *memcachedTimeout,
UpdateInterval: 1 * time.Minute,
Logger: log.With(logger, "component", "memcached"),
MaxIdleConns: *registryBurst,
})
}

// if no memcached service is specified use the ClusterIP name instead of SRV records
if *memcachedService == "" {
memcacheClient = registryMemcache.NewFixedServerMemcacheClient(memcacheConfig,
fmt.Sprintf("%s:11211", *memcachedHostname))
} else {
memcacheClient = registryMemcache.NewMemcacheClient(memcacheConfig)
}

defer memcacheClient.Stop()
cacheClient = cache.InstrumentClient(memcacheClient)

Expand Down
7 changes: 5 additions & 2 deletions deploy/flux-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
labels:
name: flux
spec:
serviceAccount: flux
serviceAccountName: flux
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well caught

volumes:
- name: git-key
secret:
Expand Down Expand Up @@ -93,7 +93,10 @@ spec:
# or with a different service name, you can supply these
# following two arguments to tell fluxd how to connect to it.
# - --memcached-hostname=memcached.default.svc.cluster.local
# - --memcached-service=memcached

# use the memcached ClusterIP service name by setting the
# memcached-service to string empty
- --memcached-service=

# this must be supplied, and be in the tmpfs (emptyDir)
# mounted above, for K8s >= 1.10
Expand Down
3 changes: 0 additions & 3 deletions deploy/memcache-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ kind: Service
metadata:
name: memcached
spec:
# The memcache client uses DNS to get a list of memcached servers and then
# uses a consistent hash of the key to determine which server to pick.
clusterIP: None
ports:
- name: memcached
port: 11211
Expand Down