You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/cloudflare-one/connections/connect-networks/configure-tunnels/remote-tunnel-permissions.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ To get the token for a remotely-managed tunnel:
17
17
<TabItemlabel="Dashboard">
18
18
1. In [Zero Trust](https://one.dash.cloudflare.com/), go to **Networks** > **Tunnels**.
19
19
2. Select a `cloudflared` tunnel and select **Edit**.
20
-
3. Copy `cloudflared` installation command.
20
+
3. Copy the `cloudflared` installation command.
21
21
4. Paste the installation command into any text editor. The token value is of the form `eyJhIjoiNWFiNGU5Z...`
[Kubernetes](https://kubernetes.io/) is a container orchestration tool that helps deploy applications onto physical or virtual machines, scale the deployment to meet traffic demands, and push updates without downtime. The Kubernetes cluster, or environment, where the application instances are running is connected internally through a private network. You can install the `cloudflared` daemon inside of the Kubernetes cluster in order to connect applications inside of the cluster to Cloudflare.
8
+
[Kubernetes](https://kubernetes.io/) is a container orchestration tool that is used to deploy applications onto physical or virtual machines, scale the deployment to meet traffic demands, and push updates without downtime. The Kubernetes cluster, or environment, where the application instances are running is connected internally through a private network. You can install the `cloudflared` daemon inside of the Kubernetes cluster in order to connect applications inside of the cluster to Cloudflare.
9
9
10
10
This guide will cover how to expose a Kubernetes service to the public Internet using a [remotely-managed](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#remotely-managed-tunnel) Cloudflare Tunnel. For the purposes of this example, we will deploy a basic web application alongside `cloudflared` in Google Kubernetes Engine (GKE). The same principles apply to any other Kubernetes environment (such as `minikube`, `kubeadm`, or a cloud-based Kubernetes service) where `cloudflared` can connect to Cloudflare's network.
11
11
@@ -17,7 +17,7 @@ If you are looking to set up a [locally-managed tunnel](/cloudflare-one/connecti
17
17
18
18

19
19
20
-
As shown in the diagram, we recommend setting up `cloudflared` as an adjacent [deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) to the application deployments. Having a separate Kubernetes deployment for `cloudflared` allows you to scale `cloudflared` independently of the application. In the `cloudflared` deployment, you can spin up [multiple replicas](/cloudflare-one/connections/connect-networks/configure-tunnels/tunnel-availability/) running the same Cloudflare Tunnel -- there is no need to build a dedicated tunnel for each pod. Each `cloudflared` replica / pod can reach all Kubernetes services in the cluster.
20
+
As shown in the diagram, we recommend setting up `cloudflared` as an adjacent [deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) to the application deployments. Having a separate Kubernetes deployment for `cloudflared` allows you to scale `cloudflared` independently of the application. In the `cloudflared` deployment, you can spin up [multiple replicas](/cloudflare-one/connections/connect-networks/configure-tunnels/tunnel-availability/) running the same Cloudflare Tunnel -- there is no need to build a dedicated tunnel for each `cloudflared`pod. Each `cloudflared` replica / pod can reach all Kubernetes services in the cluster.
21
21
22
22
:::note
23
23
We do not recommend using `cloudflared` in autoscaling setups because downscaling (removing replicas) will break existing user connections to that replica. Additionally, `cloudflared` does not load balance across replicas; replicas are strictly for high availability. To load balance traffic to your nodes, you can use [Cloudflare Load Balancer](/load-balancing/private-network/) or a third-party load balancer.
@@ -27,75 +27,189 @@ Once the cluster is connected to Cloudflare, you can configure Cloudflare Tunnel
27
27
28
28
## Prerequisites
29
29
30
+
To complete the following procedure, you will need:
31
+
-[A Google Cloud Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project)
32
+
-[A zone on Cloudflare](/fundamentals/manage-domains/add-site/)
33
+
30
34
## 1. Create a GKE cluster
31
35
36
+
To create a new Kubernetes cluster in Google Cloud:
37
+
38
+
1. Open [Google Cloud](https://console.cloud.google.com/) and go to **Kubernetes Engine**.
39
+
2. In **Clusters**, select **Create**.
40
+
3. Name the cluster. In this example, we will name it `cloudflare-tunnel`.
41
+
4. (Optional) Choose your desired region and other cluster specifications. For this example, we will use the default specifications.
42
+
5. Select **Create**.
43
+
6. To connect to the cluster:
44
+
1. Select the three-dot menu.
45
+
2. Select **Connect**.
46
+
3. Select **Run in Cloud Shell** to open a terminal in the browser.
47
+
4. Select **Authorize**.
48
+
5. Press Enter to run the pre-populated `gcloud` command.
49
+
6. (Recommended) In the Cloud Shell menu, select **Open Editor** to launch the built-in IDE.
50
+
7. Run the following command to check the cluster status:
A pod represents an instance of a running process in the cluster. In this example, we will deploy the [httpbin](https://httpbin.org/) application with two pods and make the pods accessible inside the cluster at `httpbin-service:80`.
62
+
63
+
1. Create a folder for your Kubernetes manifest files:
64
+
65
+
```sh
66
+
mkdir tunnel-example
67
+
```
68
+
69
+
2. Change into the directory:
70
+
71
+
```sh
72
+
cd tunnel-example
73
+
```
32
74
33
-
- Install the [gcloud CLI](https://cloud.google.com/sdk/docs/install) and [kubectl CLI](https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl).
34
-
- In the GCP console create a new Kubernetes cluster.
35
-
- In order to connect to the cluster, select the three dots and then connect from the drop down.
36
-
- Copy the command that appears and paste it into your local terminal.
75
+
4. In the `tunnel-example` directory, create a new file called `httpbin.yaml`. This file defines the Kubernetes deployment for the httpbin app.
37
76
77
+
```yaml title="httpbin.yaml"
78
+
apiVersion: apps/v1
79
+
kind: Deployment
80
+
metadata:
81
+
name: httpbin-deployment
82
+
namespace: default
83
+
spec:
84
+
replicas: 2
85
+
selector:
86
+
matchLabels:
87
+
app: httpbin
88
+
template:
89
+
metadata:
90
+
labels:
91
+
app: httpbin
92
+
spec:
93
+
containers:
94
+
- name: httpbin
95
+
image: kennethreitz/httpbin:latest
96
+
imagePullPolicy: IfNotPresent
97
+
ports:
98
+
- containerPort: 80
99
+
```
38
100
39
-
##Create pods for the web app
101
+
5. Create a new `httpbinsvc.yaml` file. This file defines a Kubernetes service that allows other apps in the cluster (such as `cloudflared`) to access the set of httpbin pods.
40
102
103
+
```yaml title="httpbinsvc.yaml"
104
+
apiVersion: v1
105
+
kind: Service
106
+
metadata:
107
+
name: httpbin-service
108
+
namespace: default
109
+
spec:
110
+
type: LoadBalancer
111
+
selector:
112
+
app: httpbin
113
+
ports:
114
+
- port: 80
115
+
targetPort: 80
116
+
```
41
117
118
+
6. Use the following command to run the application inside the cluster:
42
119
43
-
A pod is the basic deployable object that Kubernetes creates. It represents an instance of a running process in the cluster. The following .yml file ( httpbin-app.yml) will create a pod that contains the httpbin application. It will create two replicas so as to prevent any downtime. The application will be accessible inside the cluster at web-service:80.
120
+
```sh
121
+
kubectl create -f httpbin.yaml -f httpbinsvc.yaml
122
+
```
44
123
45
-
```yaml
46
-
apiVersion: apps/v1
47
-
kind: Deployment
48
-
metadata:
49
-
name: httpbin-deployment
50
-
spec:
51
-
selector:
52
-
matchLabels:
53
-
app: httpbin
54
-
replicas: 2
55
-
template:
56
-
metadata:
57
-
labels:
58
-
app: httpbin
59
-
spec:
60
-
containers:
61
-
- name: httpbin
62
-
image: kennethreitz/httpbin:latest
63
-
ports:
64
-
- containerPort: 80
65
-
---
66
-
apiVersion: v1
67
-
kind: Service
68
-
metadata:
69
-
name: web-service
70
-
spec:
71
-
selector:
72
-
app: httpbin
73
-
ports:
74
-
- protocol: TCP
75
-
port: 80
76
-
```
124
+
7. Check the status of your deployment:
77
125
78
-
Using the following command the application will begin to run inside the cluster.
Applications must be packaged into a containerized image, such as a Docker image, before you can run it in Kubernetes. Kubernetes uses the image to spin up multiple instances of the application.
148
+
1. Open a new browser tab and log in to [Zero Trust](https://one.dash.cloudflare.com).
93
149
94
-
## Store the tunnel token
150
+
2. Go to **Networks** > **Tunnels**.
95
151
96
-
## Create pods for cloudflared
152
+
3. Select **Create a tunnel**.
153
+
154
+
4. Choose **Cloudflared** for the connector type and select **Next**.
155
+
156
+
5. Enter a name for your tunnel (for example, `gke`).
157
+
158
+
6. Select **Save tunnel**.
159
+
160
+
7. Under **Choose an environment**, select **Docker**.
161
+
162
+
Applications must be packaged into a containerized image before you can run it in Kubernetes. Therefore, we will use the `cloudflared` Docker container image to deploy the tunnel in Kubernetes.
163
+
164
+
8. Instead of running the installation command, copy just the token value rather than the whole command. The token value is of the form `eyJhIjoiNWFiNGU5Z...` You will need the token for the Kubernetes manifest file.
165
+
166
+
Leave this browser tab open while we finish up the Kubernetes deployment.
167
+
168
+
## 4. Store the tunnel token
169
+
170
+
Create a [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/) that contains the tunnel token. The tunnel token must be encoded as a base64-encoded string before it can be stored in the secret. The encoding is not meant to protect the token from being read but to allow for the safe handling of binary data within Kubernetes.
97
171
172
+
1. Convert the tunnel token into base64 format:
98
173
174
+
```sh
175
+
'eyJhIjoiNWFiNGU5Z...'| base64
176
+
```
177
+
178
+
```sh output
179
+
ZXlKa...NKOQo=
180
+
```
181
+
182
+
2. In GKE Cloud Shell, create a `tunnel-token.yaml` file with the following content. Make sure to replace `<base64_tunnel_token>` with your base64-encoded token value (`ZXlKa...NKOQo=`).
183
+
184
+
```yaml title="tunnel-token.yaml"
185
+
apiVersion: v1
186
+
data:
187
+
token: <base64_tunnel_token>
188
+
kind: Secret
189
+
metadata:
190
+
name: tunnel-token
191
+
namespace: default
192
+
type: Opaque
193
+
```
194
+
195
+
3. Create the secret:
196
+
197
+
```sh
198
+
kubectl create -f tunnel-token.yaml
199
+
```
200
+
201
+
4. Check the newly created secret:
202
+
203
+
```sh
204
+
kubectl get secrets
205
+
```
206
+
207
+
```sh output
208
+
NAME TYPE DATA AGE
209
+
tunnel-token Opaque 1 100s
210
+
```
211
+
212
+
## Create pods for cloudflared
99
213
100
214
The tunnel can be created through the dashboard using [this guide](/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/). Instead of running the command to install a connector you will select docker as the environment and copy just the token rather than the whole command. Configure the tunnel to route to k8.example.com from the service [http://web-service:80](http://web-service:80). Create the cloudflared-deployment.yml file with the following content.
0 commit comments