---
layout: docs
page_title: Deploy Consul on self-hosted Kubernetes
description: >-
  The process for installing Consul on Kubernetes is the same as installing it on cloud-hosted k8s platforms, but requires additional configuration. Learn how to pre-define Persistent Volume Claims (PVCs) and a default storage class for server agents.
---

# Deploy Consul on self-hosted Kubernetes

This topic describes how to deploy a Consul datacenter to an a self-hosted Kubernetes cluster. The instructions are the same as for cloud-hosted Kubernetes, but you may need to pre-define Persistent Volume Claims (PVCs) and a default storage class for server agents.

Refer to the [Deploy Consul with Helm](/consul/docs/deploy/server/k8s/helm) and [Deploy Consul with `consul-k8s`](/consul/docs/deploy/server/k8s/consul-k8s) for the general installation process.

## Predefined persistent volume claims (PVCs)

If running a self-hosted Kubernetes installation, you may need to pre-create the persistent volumes for the stateful set that the Consul servers run in.

The only way to use a pre-created PVC is to name them in the format Kubernetes expects.

```text
data-<kubernetes namespace>-<helm release name>-consul-server-<ordinal>
```

The Kubernetes namespace you are installing into, Helm release name, and ordinal must match between your Consul servers and your pre-created PVCs. You only need as many PVCs as you have Consul servers. For example, given a Kubernetes namespace of "vault," a release name of "consul," and 5 servers, you would need to create PVCs with the following names.

```text
data-vault-consul-consul-server-0
data-vault-consul-consul-server-1
data-vault-consul-consul-server-2
data-vault-consul-consul-server-3
data-vault-consul-consul-server-4
```

## Storage class

Your Kubernetes installation must either have a default storage class specified (refer to [Storage classes](https://kubernetes.io/docs/concepts/storage/storage-classes/) and [Change default storage class](https://kubernetes.io/docs/tasks/administer-cluster/change-default-storage-class/)) or you must specify the storage class for the Consul servers.

```yaml
server:
  storageClass: your-class
```

Refer tothe [Helm reference](/consul/docs/reference/k8s/helm#v-server-storageclass) for more information.