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

Commit

Permalink
Merge pull request #1618 from weaveworks/memcached-srv
Browse files Browse the repository at this point in the history
Use ClusterIP service name for connecting to memcached
  • Loading branch information
stefanprodan authored Dec 27, 2018
2 parents 39901c6 + 23956ee commit 727fb81
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 7 deletions.
17 changes: 17 additions & 0 deletions chart/flux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## 0.6.0 (TBA)

**Note** To fix the connectivity problems between Flux and memcached we've changed the
memcached service from headless to ClusterIP. This change will make the Helm upgrade fail
with `ClusterIP field is immutable`.

Before upgrading to 0.6.0 you have to delete the memcached headless service:

```bash
kubectl -n flux delete svc flux-memcached
```

### Improvements

- Use ClusterIP service name for connecting to memcached
[weaveworks/flux#1618](https://github.com/weaveworks/flux/pull/1618)

## 0.5.2 (2018-12-20)

### Improvements
Expand Down
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
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

0 comments on commit 727fb81

Please sign in to comment.