赞
踩
本文是spring-cloud-kubernetes实战,主要内容是在kubernetes上部署两个应用:provider-service和consumer-service,通过spring-cloud-kubernetes提供的注册发现能力,实现consumer-service调用provider-service提供的http服务;
请确保你已经在服务器上搭建kubernetes集群
1.创建maven项目,添加如下pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.purcotton</groupId> <artifactId>k8sprovider</artifactId> <version>0.0.1-SNAPSHOT</version> <name>k8sprovider</name> <description>Demo project for k8sprovider</description> <properties> <java.version>1.8</java.version> <spring.cloud.k8s.version>1.1.6.RELEASE</spring.cloud.k8s.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-kubernetes-dependencies</artifactId> <version>${spring.cloud.k8s.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。