Compare commits
5 Commits
44a23ac542
...
48b3d32ac6
Author | SHA1 | Date |
---|---|---|
dzj | 48b3d32ac6 | |
dzj | 785dc5a239 | |
dzj | 32b95ffba0 | |
dzj | 1acc00cd26 | |
dzj | e2f357e4af |
|
@ -0,0 +1,61 @@
|
|||
机器节点准备:
|
||||
需要一台manager机器,内存和硬盘大一点,多台worker机器。
|
||||
1、安装alma Linux 9.3,设置主机名、静态IP。
|
||||
2、设置主机名。sudo hostnamectl status
|
||||
sudo hostnamectl set-hostname [swarm-manager01、swarm-worker01等等]
|
||||
3、设置静态IP,swarm mode需要使用静态IP,不能使用动态IP。
|
||||
sudo vim /etc/NetworkManager/system-connections/ens160.nmconnection
|
||||
...
|
||||
[ipv4]
|
||||
address1=92.168.31.251/24,192.168.31.1 (ip自己替换)
|
||||
dns=114.114.114.114;
|
||||
method=manual
|
||||
...
|
||||
|
||||
nmcli c reload # 重新加载配置文件
|
||||
nmcli c up ens160
|
||||
4、关闭防火墙,sudo systemctl stop firewalld
|
||||
sudo systemctl disable firewalld
|
||||
sudo systemctl disable --now firewalld
|
||||
sudo firewall-cmd --state
|
||||
5、关闭SELinux,sudo setenforce 0
|
||||
sudo sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
|
||||
sudo sestatus
|
||||
6、主机系统时间同步配置,
|
||||
sudo yum install -y chrony
|
||||
sudo vim /etc/chrony.conf
|
||||
注释掉第三行原有的时间服务器地址,设置为阿里云的时间服务地址:
|
||||
# pool 2.almalinux.pool.ntp.org iburst
|
||||
pool ntp1.aliyun.com iburst
|
||||
....
|
||||
sudo systemctl enable --now chronyd
|
||||
sudo chronyc -a makestep
|
||||
|
||||
|
||||
Docker install
|
||||
|
||||
1、 sudo yum install -y yum-utils
|
||||
2、 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
3、 sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
4、 sudo usermod -aG docker $USER
|
||||
5、 newgrp docker
|
||||
6、 sudo systemctl enable docker.service
|
||||
7、 sudo systemctl enable containerd.service
|
||||
8、 sudo systemctl start docker
|
||||
9、 docker run hello-world
|
||||
|
||||
delete swarm
|
||||
On manager机器上,执行:docker swarm leave --force
|
||||
|
||||
Create a swarm
|
||||
On manager机器上
|
||||
1、 docker swarm init --advertise-addr 192.168.3.188
|
||||
记住输出的命令
|
||||
2、 docker info
|
||||
3、 docker node ls
|
||||
|
||||
On worker机器上
|
||||
在manager机器上执行docker swarm join-token worker可以再次获取token
|
||||
|
||||
1、docker swarm join --token xxx【刚才输出的命令】
|
||||
2、在manager机器上执行:docker node ls
|
28
pom.xml
28
pom.xml
|
@ -12,7 +12,7 @@
|
|||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.2.2</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
|
@ -41,6 +41,17 @@
|
|||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://svn.youshengyun.com:3000/api/packages/risesoft/maven</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>gitea</id>
|
||||
<url>https://svn.youshengyun.com:3000/api/packages/risesoft/maven</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<spring-cloud.version>2023.0.0</spring-cloud.version>
|
||||
|
@ -145,7 +156,8 @@
|
|||
<BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
|
||||
<BP_JVM_VERSION>21</BP_JVM_VERSION>
|
||||
</env>
|
||||
<name>svn.youshengyun.com:9923/${project.artifactId}-jvm:${project.version}</name>
|
||||
<name>
|
||||
svn.youshengyun.com:9923/${project.artifactId}-jvm:${project.version}</name>
|
||||
<publish>true</publish>
|
||||
</image>
|
||||
<docker>
|
||||
|
@ -174,7 +186,8 @@
|
|||
<image>eclipse-temurin:21-jre</image>
|
||||
</from>
|
||||
<to>
|
||||
<image>svn.youshengyun.com:9923/${project.artifactId}-jib</image>
|
||||
<image>
|
||||
svn.youshengyun.com:9923/${project.artifactId}-jib</image>
|
||||
<tags>
|
||||
<tag>${project.version}</tag>
|
||||
</tags>
|
||||
|
@ -219,14 +232,17 @@
|
|||
<builder>paketobuildpacks/builder-jammy-tiny</builder>
|
||||
<buildpacks>
|
||||
<buildpack>gcr.io/paketo-buildpacks/graalvm</buildpack>
|
||||
<buildpack>gcr.io/paketo-buildpacks/java-native-image</buildpack>
|
||||
<buildpack>
|
||||
gcr.io/paketo-buildpacks/java-native-image</buildpack>
|
||||
</buildpacks>
|
||||
<env>
|
||||
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
|
||||
<BP_JVM_VERSION>21</BP_JVM_VERSION>
|
||||
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-preview</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
|
||||
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
|
||||
--enable-preview</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
|
||||
</env>
|
||||
<name>svn.youshengyun.com:9923/${project.artifactId}-native:${project.version}</name>
|
||||
<name>
|
||||
svn.youshengyun.com:9923/${project.artifactId}-native:${project.version}</name>
|
||||
<publish>true</publish>
|
||||
</image>
|
||||
<docker>
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
version: '3.2'
|
||||
|
||||
services:
|
||||
agent:
|
||||
image: portainer/agent:2.19.4
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /var/lib/docker/volumes:/var/lib/docker/volumes
|
||||
networks:
|
||||
- agent_network
|
||||
deploy:
|
||||
mode: global
|
||||
placement:
|
||||
constraints: [node.platform.os == linux]
|
||||
|
||||
portainer:
|
||||
image: portainer/portainer-ce:2.19.4
|
||||
command: -H tcp://tasks.agent:9001 --tlsskipverify
|
||||
ports:
|
||||
- "9443:9443"
|
||||
- "9000:9000"
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- portainer_data:/data
|
||||
networks:
|
||||
- agent_network
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
node.role: manager
|
||||
node.hostname: swarm-manager01
|
||||
|
||||
networks:
|
||||
agent_network:
|
||||
driver: overlay
|
||||
attachable: true
|
||||
|
||||
volumes:
|
||||
portainer_data:
|
|
@ -4,7 +4,7 @@
|
|||
./mvnw.cmd clean spring-boot:build-image -Pnative -Dmaven.test.skip=true
|
||||
|
||||
#运行docker image
|
||||
docker compose -f compose.yml up -d
|
||||
docker compose -f compose-dev.yml up -d
|
||||
|
||||
docker compose -f compose-demo01-jib.yml up -d
|
||||
docker compose -f compose-demo01-jvm.yml up -d
|
||||
|
|
Loading…
Reference in New Issue