MiniKube Networking Connection Guide
Organizations that have set up the Altinity Kubernetes Operator using minikube can connect it to an external network through the following steps.
Prerequisites
The following guide is based on an installed Altinity Kubernetes Operator cluster using minikube
for an Ubuntu Linux operating system.
- For instructions on setting up
minikube
for ubuntu 20.04, see the Install minikube for Linux guide. - For instructions on installing the Altinity Kubernetes Operator, see the Altinity Kubernetes Operator Quick Start Guide or the Altinity Kubernetes Operator install guides.
Network Connection Guide
The proper way to connect to the ClickHouse cluster is through the LoadBalancer created during the ClickHouse cluster created process. For example, the following ClickHouse cluster has 2 shards in one replica, applied to the namespace test
:
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "demo-01"
spec:
configuration:
clusters:
- name: "demo-01"
layout:
shardsCount: 2
replicasCount: 1
This generates the following services in the namespace test
:
kubectl get service -n test
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
chi-demo-01-demo-01-0-0 ClusterIP None <none> 8123/TCP,9000/TCP,9009/TCP 22s
chi-demo-01-demo-01-1-0 ClusterIP None <none> 8123/TCP,9000/TCP,9009/TCP 5s
clickhouse-demo-01 LoadBalancer 10.96.67.44 <pending> 8123:32766/TCP,9000:31368/TCP 38s
The LoadBalancer alternates which of the ClickHouse shards to connect to, and should be where all ClickHouse clients connect to.
To open a connection from external networks to the LoadBalancer, use the kubectl port-forward
command in the following format:
kubectl port-forward service/{LoadBalancer Service} -n {NAMESPACE} --address={IP ADDRESS} {TARGET PORT}:{INTERNAL PORT}
Replacing the following:
LoadBalancer Service
: the LoadBalancer service to connect external ports to the Kubernetes environment.NAMESPACE
: The namespace for the LoadBalancer.IP ADDRESS
: The IP address to bind the service to on the machine runningminikube
, or0.0.0.0
to find all IP addresses on theminikube
server to the specified port.TARGET PORT
: The external port that users will connect to.INTERNAL PORT
: The port within the Altinity Kubernetes Operator network.
The kubectl port-forward
command must be kept running in the terminal, or placed into the background with the &
operator.
In the example above, the following settings will be used to bind all IP addresses on the minikube
server to the service clickhouse-demo-01
for ports 9000
and 8123
in the background:
kubectl port-forward service/clickhouse-demo-01 -n test --address=0.0.0.0 9000:9000 8123:8123 &
To test the connection, connect to the external IP address via curl
. For ClickHouse HTTP, OK
will be returned, while for port 9000
a notice requesting use of port 8123
will be displayed:
curl http://localhost:9000
Handling connection for 9000
Port 9000 is for clickhouse-client program
You must use port 8123 for HTTP.
curl http://localhost:8123
Handling connection for 8123
Ok.
Once verified, connect to the ClickHouse cluster via either HTTP or ClickHouse TCP as needed.