This article will teach us how to set up a development environment in you local machine, including java/k8s/spring cloud kubernetes, etc.
OS
reference: https://docs.microsoft.com/en-us/windows/wsl/install-win10
I’d recommend you base on WSL system to develop, if you don’t know what’s the wsl, look at this article
Installing WSL as below:
1 | #Step 1 - Enable WSL |
Windows Terminal
I’d highly recommend using Windows terminal in Windows 10, it’s pretty handly.
Reference: https://docs.microsoft.com/en-us/windows/terminal/get-started
Adding git-bash support:
1 | { |
Install Local Docker(Optional)
If you want to use the remote development environment, don’t need it.
Reference:
- https://docs.docker.com/docker-for-windows/wsl/
- https://kubernetes.io/blog/2020/05/21/wsl-docker-kubernetes-on-the-windows-desktop/
Just need to install Docker-Desktop for Windows, and select the ubuntu at “Setting->Resources/WSL Integration”, that’s all.
Install Local Kubernetes(Optional)
If you want to use the remote development environment, don’t need it.
Just need to enable kubernetes in “Docker-Desktop Settings”, that’s all. But you need to set the proxy in the Docker Setting, or you will get the failure by Downloading google’s containers.
1 | http://192.168.101.175:1082 |
Enable Ingress Addon:
Reference:https://github.com/docker/for-win/issues/7094
1 | #https://kubernetes.github.io/ingress-nginx/deploy/#docker-for-mac |
demo.yaml
1 | kind: Service |
Remote Kubernetes Environment
I’d recommend installing docker and kubernetes on the remote machine, and all of developers can share it and save some of local resources.
Docker
Ubuntu Reference: http://blog.gcalls.cn/blog/2018/12/ubuntu-os.html#Docker
For CentOS:
1 | #https://www.cnblogs.com/763977251-sg/p/11837130.html |
Kubernetes
Kubectl
Following the instructions to install the k8s client tools:
1 | #For MAC |
microk8s
Recommend using microk8s on Linux. It’s the best performance.
Reference:
https://jiajunhuang.com/articles/2019_11_17-microk8s.md.html
https://microk8s.io/#quick-start
https://microk8s.io/docs
https://www.cnblogs.com/xiao987334176/p/10931290.html
1 | #For ubuntu: |
Harbor
Harbor is an open source trusted cloud native registry project that stores, signs, and scans content. Harbor extends the open source Docker Distribution by adding the functionalities usually required by users such as security, identity and management. Having a registry closer to the build and run environment can improve the image transfer efficiency. Harbor supports replication of images between registries, and also offers advanced security features such as user management, access control and activity auditing.
1 | #Habor: |
docker registry2
1 | sudo su - dev |
kind
Not Recommend.
Reference:https://kind.sigs.k8s.io/docs/user/quick-start/
1 | # Download the latest version of Kind |
Notice: Kind clusters based on docker, cannot communicate with the internal docker container. Adding the extraPortMappings:
Reference:https://kind.sigs.k8s.io/docs/user/using-wsl2/
1 | # cluster-config.yml |
Local development
Reference:
- https://www.telepresence.io/discussion/overview
- https://github.com/cesartl/telepresence-k8s
- https://kubernetes.io/zh/docs/tasks/debug-application-cluster/local-debugging/
- https://cloud.google.com/community/tutorials/developing-services-with-k8s
telepresence
https://www.telepresence.io/reference/windows
1 | #For Windows: |
Develop
- https://anjia0532.github.io/2019/01/21/debug-cloud-native/
- https://www.telepresence.io/tutorials/docker
- https://www.telepresence.io/tutorials/kubernetes
- https://github.com/telepresenceio/telepresence/tree/master/examples/guestbook
- https://github.com/cesartl/telepresence-k8s
1 | #https://www.telepresence.io/tutorials/java |
Notice:
Making sure “KUBERNETES_NAMESPACE” is set in the OS environment. You can set it of “remoteEnv” of devcontainer.json file if you develop with VSCODE.
JRebel
1 | #https://www.jrebel.com/success/products/jrebel/free-trial |
demo:
- https://github.com/zq2599/blog_demos
- https://xinchen.blog.csdn.net/article/details/92394559
- http://www.mydlq.club/article/31
1 | #account-service |
Notice: Some of spring-boot versions don’t support remote debug through mvnDebug or MAVEN_DEBUG_OPTS:
https://docs.spring.io/spring-boot/docs/2.3.4.RELEASE/maven-plugin/reference/html/
Fixed this by:
1 | <plugin> |
Or:
1 | mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000" |
kubernetes-maven-plugin
https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin
Building Kubernetes, strongly recommended.
1 | #Copying remote config into "~/.kube/config" of local |