Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
48 changes: 41 additions & 7 deletions content/en/docs/v3.5/tutorials/how-to-create-lease.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,57 @@
---
title: How to create lease
description: Guide to creating a lease in etcd
title: Granting and revoking leases
description: Guide to granting and revoking leases in etcd
weight: 700
---

`lease` to write with TTL:
## Prerequisites

- A running etcd cluster (see [getting started](/docs/v3.5/quickstart/))
- `etcdctl` installed and configured

![07_etcdctl_lease_2016050501](https://storage.googleapis.com/etcd/demo/07_etcdctl_lease_2016050501.gif)
The following variables are used in this guide:

```shell
- `$ENDPOINTS` — the etcd endpoint(s), e.g. `localhost:2379`
- `lease grant` — creates a new lease with a TTL (time-to-live) in seconds
- `put --lease` — attaches a key to a lease so it expires with it
- `lease keep-alive` — refreshes a lease to prevent it from expiring
- `lease revoke` — immediately expires a lease and deletes its keys

For more information on leases, see [Interacting with etcd: Grant leases](/docs/v3.5/dev-guide/interacting_v3/#grant-leases).

## Grant a lease

Grant a lease with a TTL of 300 seconds:

```bash
etcdctl --endpoints=$ENDPOINTS lease grant 300
# lease 2be7547fbc6a5afa granted with TTL(300s)
```

Attach a key to the lease so it is automatically deleted when the lease expires:

```bash
etcdctl --endpoints=$ENDPOINTS put sample value --lease=2be7547fbc6a5afa
etcdctl --endpoints=$ENDPOINTS get sample
```

Keep the lease alive by refreshing it before it expires:

```bash
etcdctl --endpoints=$ENDPOINTS lease keep-alive 2be7547fbc6a5afa
```

## Revoke a lease

Revoke the lease immediately, which also deletes all keys attached to it:

```bash
etcdctl --endpoints=$ENDPOINTS lease revoke 2be7547fbc6a5afa
# or after 300 seconds
etcdctl --endpoints=$ENDPOINTS get sample
```

After revocation (or after the TTL expires), the key is no longer accessible:

```bash
etcdctl --endpoints=$ENDPOINTS get sample
# (empty response)
```
48 changes: 41 additions & 7 deletions content/en/docs/v3.6/tasks/developer/how-to-create-lease.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,57 @@
---
title: How to create lease
description: Guide to creating a lease in etcd
title: Granting and revoking leases
description: Guide to granting and revoking leases in etcd
weight: 700
---

`lease` to write with TTL:
## Prerequisites

- A running etcd cluster (see [getting started](/docs/v3.5/quickstart/))
- `etcdctl` installed and configured

![07_etcdctl_lease_2016050501](https://storage.googleapis.com/etcd/demo/07_etcdctl_lease_2016050501.gif)
The following variables are used in this guide:

```shell
- `$ENDPOINTS` — the etcd endpoint(s), e.g. `localhost:2379`
- `lease grant` — creates a new lease with a TTL (time-to-live) in seconds
- `put --lease` — attaches a key to a lease so it expires with it
- `lease keep-alive` — refreshes a lease to prevent it from expiring
- `lease revoke` — immediately expires a lease and deletes its keys

For more information on leases, see [Interacting with etcd: Grant leases](/docs/v3.5/dev-guide/interacting_v3/#grant-leases).

## Grant a lease

Grant a lease with a TTL of 300 seconds:

```bash
etcdctl --endpoints=$ENDPOINTS lease grant 300
# lease 2be7547fbc6a5afa granted with TTL(300s)
```

Attach a key to the lease so it is automatically deleted when the lease expires:

```bash
etcdctl --endpoints=$ENDPOINTS put sample value --lease=2be7547fbc6a5afa
etcdctl --endpoints=$ENDPOINTS get sample
```

Keep the lease alive by refreshing it before it expires:

```bash
etcdctl --endpoints=$ENDPOINTS lease keep-alive 2be7547fbc6a5afa
```

## Revoke a lease

Revoke the lease immediately, which also deletes all keys attached to it:

```bash
etcdctl --endpoints=$ENDPOINTS lease revoke 2be7547fbc6a5afa
# or after 300 seconds
etcdctl --endpoints=$ENDPOINTS get sample
```

After revocation (or after the TTL expires), the key is no longer accessible:

```bash
etcdctl --endpoints=$ENDPOINTS get sample
# (empty response)
```
48 changes: 41 additions & 7 deletions content/en/docs/v3.7/tasks/developer/how-to-create-lease.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,57 @@
---
title: How to create lease
description: Guide to creating a lease in etcd
title: Granting and revoking leases
description: Guide to granting and revoking leases in etcd
weight: 700
---

`lease` to write with TTL:
## Prerequisites

- A running etcd cluster (see [getting started](/docs/v3.5/quickstart/))
- `etcdctl` installed and configured

![07_etcdctl_lease_2016050501](https://storage.googleapis.com/etcd/demo/07_etcdctl_lease_2016050501.gif)
The following variables are used in this guide:

```shell
- `$ENDPOINTS` — the etcd endpoint(s), e.g. `localhost:2379`
- `lease grant` — creates a new lease with a TTL (time-to-live) in seconds
- `put --lease` — attaches a key to a lease so it expires with it
- `lease keep-alive` — refreshes a lease to prevent it from expiring
- `lease revoke` — immediately expires a lease and deletes its keys

For more information on leases, see [Interacting with etcd: Grant leases](/docs/v3.5/dev-guide/interacting_v3/#grant-leases).

## Grant a lease

Grant a lease with a TTL of 300 seconds:

```bash
etcdctl --endpoints=$ENDPOINTS lease grant 300
# lease 2be7547fbc6a5afa granted with TTL(300s)
```

Attach a key to the lease so it is automatically deleted when the lease expires:

```bash
etcdctl --endpoints=$ENDPOINTS put sample value --lease=2be7547fbc6a5afa
etcdctl --endpoints=$ENDPOINTS get sample
```

Keep the lease alive by refreshing it before it expires:

```bash
etcdctl --endpoints=$ENDPOINTS lease keep-alive 2be7547fbc6a5afa
```

## Revoke a lease

Revoke the lease immediately, which also deletes all keys attached to it:

```bash
etcdctl --endpoints=$ENDPOINTS lease revoke 2be7547fbc6a5afa
# or after 300 seconds
etcdctl --endpoints=$ENDPOINTS get sample
```

After revocation (or after the TTL expires), the key is no longer accessible:

```bash
etcdctl --endpoints=$ENDPOINTS get sample
# (empty response)
```