{"id":19699129,"url":"https://github.com/castai/k8s-memcache-selector","last_synced_at":"2025-06-10T20:11:48.553Z","repository":{"id":64308105,"uuid":"521231552","full_name":"castai/k8s-memcache-selector","owner":"castai","description":"Memcache server discovery based on Kubernetes endpoints","archived":false,"fork":false,"pushed_at":"2022-08-04T14:12:18.000Z","size":21,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-29T12:49:02.957Z","etag":null,"topics":["golang","kubernetes","memcache"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/castai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-04T11:02:01.000Z","updated_at":"2023-12-26T03:47:01.000Z","dependencies_parsed_at":"2023-01-15T11:15:28.713Z","dependency_job_id":null,"html_url":"https://github.com/castai/k8s-memcache-selector","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castai%2Fk8s-memcache-selector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castai%2Fk8s-memcache-selector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castai%2Fk8s-memcache-selector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castai%2Fk8s-memcache-selector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/castai","download_url":"https://codeload.github.com/castai/k8s-memcache-selector/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castai%2Fk8s-memcache-selector/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259144813,"owners_count":22811926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","kubernetes","memcache"],"created_at":"2024-11-11T20:01:22.444Z","updated_at":"2025-06-10T20:11:48.532Z","avatar_url":"https://github.com/castai.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## About\n\nMemcache server discovery based on Kubernetes endpoints for [Go memcache client](https://github.com/bradfitz/gomemcache)\n\nHow it works:\n* Watches endpoints containing memcache pod ips using [tiny k8s client](https://github.com/castai/k8s-client-go)\n* Implements ServerPicker interface to dynamically update memcache ip addresses.\n\n## Use cases\n\nIn dynamic environments like Kubernetes both clients (pods calling memcache) and memcache pods could change.\nThere are few issues:\n1. Calling memcache using clusterIP service is quite useless (unless you have one replica) as kernel will perform round-robin across service endpoints.\n2. You can enable sessionAffinity. This will ensure that client pod always goes to the same memcache instance. But what happens if pods are redeployed?\n3. Using StatefulSet with headless services and passing each endpoint is kind of static too.\n\n## Installing\n\n```\ngo get github.com/castai/k8s-memcache-selector\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/bradfitz/gomemcache/memcache\"\n\n\tselector \"github.com/castai/k8s-memcache-selector\"\n)\n\nfunc main() {\n\tss, err := selector.NewServerList(context.Background(), \"memcache-headless:11211\")\n\tif err != nil {\n\t\tlog.Fatalf(\"creating server selector: %v\", err)\n\t}\n\tcache := memcache.NewFromSelector(ss)\n\n\t// Use cache..\n}\n```\n\n## Permissions\n\nYour application needs permission to get and watch endpoints. Example manifest:\n\n```yaml\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n  name: endpoints-watcher\n  namespace: e2e\n---\nkind: Role\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n  name: endpoints-watcher\nrules:\n  - apiGroups: [ \"\" ]\n    resources: [ \"endpoints\" ]\n    verbs: [ \"get\", \"watch\" ]\n---\nkind: RoleBinding\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n  name: endpoints-watcher\nroleRef:\n  apiGroup: rbac.authorization.k8s.io\n  kind: Role\n  name: endpoints-watcher\nsubjects:\n  - kind: ServiceAccount\n    name: endpoints-watcher\n    namespace: e2e\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: my-service\n  namespace: e2e\nspec:\n  template:\n    metadata:\n      labels:\n        app: my-service\n    spec:\n      serviceAccount: endpoints-watcher\n      containers:\n        - name: nginx\n          image: nginx\n      restartPolicy: Never\n  backoffLimit: 0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcastai%2Fk8s-memcache-selector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcastai%2Fk8s-memcache-selector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcastai%2Fk8s-memcache-selector/lists"}