This example deploys tidb instance onto a running Kubernetes cluster using Pulumi and @pulumi/kubernetes
.
Install dependencies:
$ npm install
Create a new stack:
$ pulumi stack init
Preview the deployment of the application:
$ pulumi preview
(Optional) Prepare directory for local pv (refer to name, localStorage, storageNode and storagePath in index.ts
):
# on k8s local pv node
$ mkdir -p /data/tidb
Perform the deployment:
$ pulumi up --skip-preview
This deployment is now running, and you can run commands like kubectl get pods
to see the application's resources.
Use pulumi stack output
to see the endpoint of the Service that we just deployed:
$ pulumi stack output
Forward this Service port:
$ kubectl port-forward svc/tidb 4000
Connect to tidb:
without password:
$ mysql -h 127.0.0.1 -P 4000 -u root
with password (mysql 5.7):
$ mysql -h 127.0.0.1 -P 4000 -u root -p
with password (mysql 8.0):
$ mysql -h 127.0.0.1 -P 4000 -u root -p --default-auth=mysql_native_password
When you're ready to be done with tidb, you can destroy the instance:
$ pulumi destroy --skip-preview
index.ts
Parameter | Default | Default |
---|---|---|
name | Name of pvc, deployment, service | tidb |
namespace | Namespace of resources | tidb |
imageVersion | Image tag | latest |
storageClass | Type of persistent volume claim | local-storage |
storageSize | Size of persistent volume claim | 10Gi |
localStorage | Enable local storage | false |
storageNode | Nodename of local storage pv | node1 |
storagePath | Parent path of local storage pv | /data |
password | TiDB password, if not specified, there is no password | pa55w0rd |