Skip to content

Instantly share code, notes, and snippets.

@nastra
Forked from sbtourist/etcd-on-k8s.txt
Created July 23, 2020 13:18
Show Gist options
  • Save nastra/328036e1b993aea1eff4ead6c1fdb26f to your computer and use it in GitHub Desktop.
Save nastra/328036e1b993aea1eff4ead6c1fdb26f to your computer and use it in GitHub Desktop.
How to run ETCD on K8S locally
1. Install any local K8S distribution. I've used microk8s: https://microk8s.io/
2. Install etcd so you can use etcdctl: https://github.com/etcd-io/etcd/releases/
3. Run etcd on k8s via the Bitnami image. Using microk8s:
$> microk8s kubectl run --image=bitnami/etcd:latest etcd --env ALLOW_NONE_AUTHENTICATION=yes --labels app=etcd
4. Expose etcd as a service so you can interact with it via etcdctl installed on the host.
Service file:
apiVersion: v1
kind: Service
metadata:
name: etcd
spec:
selector:
app: etcd
ports:
- protocol: TCP
port: 2379
targetPort: 2379
Command line:
$> microk8s kubectl apply -f etcd.yaml
7. Get the etcd pod IP from:
$> microk8s kubectl describe pod etcd
8. Test it out by running on the host:
$> ./etcdctl --endpoints http://pod-ip:2379 put foo bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment