mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
kubernetes tutorial update
This commit is contained in:
parent
0d37b7b665
commit
ba78676ace
1 changed files with 30 additions and 16 deletions
|
@ -3,33 +3,32 @@ Kubernetes + ZeroTier
|
||||||
|
|
||||||
A self-authorizing Kubernetes deployment on a ZeroTier private network.
|
A self-authorizing Kubernetes deployment on a ZeroTier private network.
|
||||||
|
|
||||||
This is a quick tutorial for setting up a Kubernetes deployment which can self-authorize each new replica onto your private ZeroTier network with no additional configuration needed when you scale. The Kubernetes-specific instructions and content is based on the [hellonode](http://kubernetes.io/docs/hellonode/) tutorial.
|
This is a quick tutorial for setting up a Kubernetes deployment which can self-authorize each new replica onto your private ZeroTier network with no additional configuration needed when you scale. The Kubernetes-specific instructions and content is based on the [hellonode](http://kubernetes.io/docs/hellonode/) tutorial. All of the files discussed below can be found [here]();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Preliminary tasks
|
## Preliminary tasks
|
||||||
|
|
||||||
**Step 1: Go to [my.zerotier.com](https://www.my.zerotier.com) and generate an API key. This key will be used by ZeroTier to automatically authorize new instances of your VMs to join your deployment network during replication.
|
**Step 1: Go to [my.zerotier.com](https://my.zerotier.com) and generate an API key. This key will be used by ZeroTier to automatically authorize new instances of your VMs to join your deployment network during replication.**a
|
||||||
|
|
||||||
**Step 2: Create a new `private` network. Take note of the network ID: `nwid`
|
**Step 2: Create a new `private` network. Take note of the network ID: `nwid`**
|
||||||
|
|
||||||
**Step 3: Follow the instructions from the [hellonode](ttp://kubernetes.io/docs/hellonode/) tutorial and set up your development system (install Google Cloud SDK).
|
**Step 3: Follow the instructions from the [hellonode](ttp://kubernetes.io/docs/hellonode/) tutorial and set up your development system (install Google Cloud SDK).**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Construct docker container
|
## Construct docker container
|
||||||
|
|
||||||
Step 4: Create necessary files for inclusion in Dockerfile
|
**Step 4: Create necessary files for inclusion in Dockerfile**
|
||||||
- `mkdir ztkube`
|
- `mkdir ztkube`
|
||||||
|
|
||||||
### Add the following files to the `ztkube` directory. These files will be compiled into the Docker image.
|
Add the following files to the `ztkube` directory. These files will be compiled into the Docker image.
|
||||||
|
|
||||||
|
|
||||||
Create an empty file to specify the private deployment network you created in *Step 2*:
|
Create an empty file to specify the private deployment network you created in *Step 2*:
|
||||||
- `<nwid>.conf`
|
- `<nwid>.conf`
|
||||||
|
|
||||||
- The `entrypoint.sh` script will start the ZeroTier service in the VM, attempt to join your deployment network and automatically authorize the new VM if your network is set to private.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
./zerotier
|
./zerotier
|
||||||
|
@ -37,7 +36,7 @@ zerotier-cli join $(NWID).conf
|
||||||
zerotier-cli net-auth $(NWID) $(DEVID)
|
zerotier-cli net-auth $(NWID) $(DEVID)
|
||||||
```
|
```
|
||||||
|
|
||||||
The cli tool config `.zerotierCliSettings`, this should contain your API keys to authorize new devices on your network. In this example the default controller is hosted by us at [my.zerotier.com](https://www.my.zerotier.com). YOu can host your own network controller and you'll need to modify the cli config accordingly:
|
- The CLI tool config file `.zerotierCliSettings` should contain your API keys to authorize new devices on your network. In this example the default controller is hosted by us at [my.zerotier.com](https://my.zerotier.com). Alternatively, you can host your own network controller but you'll need to modify the CLI config file accordingly.
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
|
@ -61,8 +60,7 @@ The cli tool config `.zerotierCliSettings`, this should contain your API keys to
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
- The `Dockerfile` will copy the ZeroTier service as well as the ZeroTier CLI to the image:
|
||||||
`Dockerfile`
|
|
||||||
|
|
||||||
```
|
```
|
||||||
FROM node:4.4
|
FROM node:4.4
|
||||||
|
@ -75,22 +73,38 @@ COPY .zerotierCliSettings <settings path>?>
|
||||||
CMD node server.js
|
CMD node server.js
|
||||||
```
|
```
|
||||||
|
|
||||||
Step 5: Lastly, build the image:
|
- The `entrypoint.sh` script will start the ZeroTier service in the VM, attempt to join your deployment network and automatically authorize the new VM if your network is set to private.
|
||||||
|
|
||||||
|
**Step 5: Lastly, build the image:**
|
||||||
|
|
||||||
`docker build -t gcr.io/$PROJECT_ID/hello-node .`
|
`docker build -t gcr.io/$PROJECT_ID/hello-node .`
|
||||||
|
|
||||||
Step 6: Build and push the docker image to your *Container Registry*
|
|
||||||
|
|
||||||
|
**Step 6: Push the docker image to your *Container Registry**
|
||||||
|
|
||||||
`gcloud docker push gcr.io/$PROJECT_ID/hello-node:v1`
|
`gcloud docker push gcr.io/$PROJECT_ID/hello-node:v1`
|
||||||
|
|
||||||
Step 7: Create Kubernetes Cluster
|
|
||||||
|
|
||||||
|
**Step 7: Create Kubernetes Cluster**
|
||||||
|
|
||||||
`gcloud config set compute/zone us-central1-a`
|
`gcloud config set compute/zone us-central1-a`
|
||||||
|
|
||||||
`gcloud container clusters create hello-world`
|
`gcloud container clusters create hello-world`
|
||||||
|
|
||||||
`gcloud container clusters get-credentials hello-world`
|
`gcloud container clusters get-credentials hello-world`
|
||||||
|
|
||||||
Step 8: Create your pod
|
|
||||||
|
|
||||||
|
**Step 8: Create your pod**
|
||||||
|
|
||||||
`kubectl run hello-node --image=gcr.io/$PROJECT_ID/hello-node:v1 --port=8080`
|
`kubectl run hello-node --image=gcr.io/$PROJECT_ID/hello-node:v1 --port=8080`
|
||||||
|
|
||||||
Step 9: Scale
|
|
||||||
|
|
||||||
|
**Step 9: Scale**
|
||||||
|
|
||||||
`kubectl scale deployment hello-node --replicas=4`
|
`kubectl scale deployment hello-node --replicas=4`
|
||||||
|
|
||||||
Now, after a minute or so you can use `zerotier-cli net-members <nwid>` to show all of your VM instances on your ZeroTier deployment network. If you haven't configured your local CLI, you can simply log into [my.zerotier.com](https://my.zerotier.com), go to *Networks -> <nwid>*.
|
Now, after a minute or so you can use `zerotier-cli net-members <nwid>` to show all of your VM instances on your ZeroTier deployment network. If you haven't [configured your local CLI](), you can simply log into [my.zerotier.com](https://my.zerotier.com), go to *Networks -> <nwid>*.
|
||||||
|
|
Loading…
Add table
Reference in a new issue