Skip to content

Instantly share code, notes, and snippets.

@lalyos
Last active April 26, 2024 16:14
Show Gist options
  • Select an option

  • Save lalyos/aef94a4c23973eaee4a17bb26b6972a2 to your computer and use it in GitHub Desktop.

Select an option

Save lalyos/aef94a4c23973eaee4a17bb26b6972a2 to your computer and use it in GitHub Desktop.

Revisions

  1. lalyos revised this gist Jul 30, 2018. 1 changed file with 13 additions and 8 deletions.
    21 changes: 13 additions & 8 deletions etcd-list-keys.md
    Original file line number Diff line number Diff line change
    @@ -18,22 +18,27 @@ kubectl exec -it \
    ```

    ## Proxy to etcd
    Or if you have etcdctl installed on your host. First start a proxy to be able to connect to etcd on localhost:
    Or if you have etcdctl installed on your host. You can run `etcdctl` command on your localhost.

    ```
    kubectl port-forward -n kube-system etcd-minikube 2379:2379
    ```

    copy certificate and key from container to localhost:
    Copy certificate and key from container to localhost:
    ```
    kubectl cp kube-system/etcd-minikube:/var/lib/localkube/certs/etcd/peer.key .
    kubectl cp kube-system/etcd-minikube:/var/lib/localkube/certs/etcd/peer.crt .
    ```

    than
    Set `ETCDCTL_` environment variables
    ```
    export ETCDCTL_API=3 ETCDCTL_INSECURE_SKIP_TLS_VERIFY=true ETCDCTL_CERT=peer.crt ETCDCTL_KEY=peer.key
    export \
    ETCDCTL_API=3 \
    ETCDCTL_INSECURE_SKIP_TLS_VERIFY=true \
    ETCDCTL_CERT=peer.crt \
    ETCDCTL_KEY=peer.key
    ```
    Start a proxy (in a separate terminal) to be able to connect to etcd on localhost:
    ```
    kubectl port-forward -n kube-system etcd-minikube 2379:2379
    ```


    ```
    etcdctl get --keys-only --prefix=true "/registry/namespaces/"
  2. lalyos revised this gist Jul 30, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions etcd-list-keys.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    You can demostrate how kubernetes stores everything in etcd (v3):

    ## One-liner

  3. lalyos created this gist Jul 30, 2018.
    39 changes: 39 additions & 0 deletions etcd-list-keys.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@

    ## One-liner

    You can exec `etcdctl` rigth in the etc pod:
    ```
    kubectl exec -it \
    -n kube-system etcd-minikube \
    -- sh -c 'ETCDCTL_CACERT=/var/lib/localkube/certs/etcd/ca.crt \
    ETCDCTL_CERT=/var/lib/localkube/certs/etcd/peer.crt \
    ETCDCTL_KEY=/var/lib/localkube/certs/etcd/peer.key \
    ETCDCTL_API=3 \
    etcdctl \
    get \
    --keys-only \
    --prefix=true \
    "/registry/namespaces/" '
    ```

    ## Proxy to etcd
    Or if you have etcdctl installed on your host. First start a proxy to be able to connect to etcd on localhost:

    ```
    kubectl port-forward -n kube-system etcd-minikube 2379:2379
    ```

    copy certificate and key from container to localhost:
    ```
    kubectl cp kube-system/etcd-minikube:/var/lib/localkube/certs/etcd/peer.key .
    kubectl cp kube-system/etcd-minikube:/var/lib/localkube/certs/etcd/peer.crt .
    ```

    than
    ```
    export ETCDCTL_API=3 ETCDCTL_INSECURE_SKIP_TLS_VERIFY=true ETCDCTL_CERT=peer.crt ETCDCTL_KEY=peer.key
    ```

    ```
    etcdctl get --keys-only --prefix=true "/registry/namespaces/"
    ```