kt introduction
Manage and integrate more effectively with your Kubernetes development environment. Detailed document access link , project address access github
features
- Connection: direct access to the remote Kubernetes cluster. KT Connect sshuttle is used as a vpn tool to access the remote Kubernetes cluster network.
- Swap: developers can swap workloads to redirect requests to local applications.
- Grid: you can create a version of the grid in the local host and redirect to the local host
- Dashboard: dashboard view can help you understand how your environment is used.
Install and configure kubectl
Install kubectl
- Download bectl
from then on link Download the executable file of kubectl in. What I download here is the kubectl corresponding to our online kubernetes version. If you want to download other versions, you can copy the above link and change the version number to the corresponding one.
- Add kubectl to the PATH environment variable
Create kube folder under disk D and store kubectl in kube folder. Add D:\kube\kubectl to the PATH environment variable
- Execute the command to view the installed kubectl version number
$ kubectl version
Configure kubectl
- Store kubectl config file in ~ / kube / down~ Represents the current user directory
Create ~ / kube folder, pull the config file on the master to the local and store it in ~ / kube / folder
- Verify configuration results
$ kubectl get nodes $ kubectl get pods -n kube-system
Install configuration kt
Install ktctl
- Download ktctl
from then on link Download the executable file of ktctl in
- Add ktctl to the PATH environment variable
Store ktctl in kube folder. Add D:\kube\ktctl to the PATH environment variable
- Execute the command to view the installed ktctl version number
$ ktctl -v
Using ktctl
The command line of this document uses git bash. Most developers will install GIT and can use it directly. If you prefer windows native cmd, remember to install ssh and curl. ssh should be used when kt starts, and curl is a test connection.
Default mode
Execute command:
# Note kt that only socks5 mode can be used under windows $ ktctl -d connect --method socks5
After that, ktctl will create a socks5 proxy locally. And follow the log output setting http_proxy environment variable.
Output:
4:31PM INF ============================================================== 4:31PM INF Start SOCKS5 Proxy: export http_proxy=socks5://127.0.0.1:2223 4:31PM INF ==============================================================
Set environment variables:
# Open another window # Set the environment variable. Choose one of the following settings ## windows cmd $ set http_proxy=socks5://127.0.0.1:2223 ## git bash $ export http_proxy=socks5://127.0.0.1:2223
To access services in the cluster:
$ curl http://<POD_IP>:<PORT> $ curl http://<CLUSTER_IP>:<PORT>
Note: the above method cannot use the service name to access the service
extend
Because we can only use socks5 mode under windows, the above method can not meet some of our requirements. Here are some ways to expand. The premise of using the following methods is that your user must have read and write permission to the hosts file
- The configuration can be accessed using the service name
# --method=socks5 to use socks5 mode -- dump2hosts will synchronize all services in the namespace to the hosts file. $ ktctl connect --method=socks5 --dump2hosts # Set the environment variable. Choose one of the following settings ## windows cmd $ set http_proxy=socks5://127.0.0.1:2223 ## git bash $ export http_proxy=socks5://127.0.0.1:2223 #Accessing services within the cluster $ curl http://<POD_ IP >: < port > # local direct access to PodIP $ curl http://<CLUSTER_ IP >: < port > # local direct access to ClusterIP $ curl http://<SVC_ Name >: < port > # use the domain name of the Service to access
- Configure the corresponding namespace
# After the default ktctl is started, a deployment will be created in the default namespace, and the service access method can only be used in the default namespace # This method can specify the namespace. A deployment will be created in the specified namespace so that the access method of the service can be used in the specified namespace $ ktctl -n test connect --method=socks5 --dump2hosts # Set the environment variable. Choose one of the following settings ## windows cmd $ set http_proxy=socks5://127.0.0.1:2223 ## git bash $ export http_proxy=socks5://127.0.0.1:2223 #Accessing services within the cluster $ curl http://<POD_ IP >: < port > # local direct access to PodIP $ curl http://<CLUSTER_ IP >: < port > # local direct access to ClusterIP $ curl http://<SVC_ Name >: < port > # use the domain name of the Service to access
- Configure multiple namespaces
# The above is to specify a namespace, where multiple namespaces are configured # Configure test and monitoring namespaces $ ktctl -d connect --dump2hosts --method=socks5 --dump2hostsNS=test --dump2hostsNS=monitoring # Set the environment variable. Choose one of the following settings ## windows cmd $ set http_proxy=socks5://127.0.0.1:2223 ## git bash $ export http_proxy=socks5://127.0.0.1:2223 #Accessing services within the cluster $ curl http://<POD_ IP >: < port > # local direct access to PodIP $ curl http://<CLUSTER_ IP >: < port > # local direct access to ClusterIP $ curl http://<SVC_ NAME>.< namespace_ Name >: < port > # local access to service with namespace
If you are interested, you can install the swichyomeaga proxy plug-in on the browser and directly access the internal services of kubernetes on the web side. There are not too many demonstrations here
Transferred from: