k8s部署微服务springcloud从0-1(Eureka实现)

Posted luoguo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s部署微服务springcloud从0-1(Eureka实现)相关的知识,希望对你有一定的参考价值。

Eureka服务搭建

1.pom配置文件

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>sm1234_parent</artifactId>
        <groupId>cn.sm1234</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>sm1234_eureka</artifactId>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
    </dependencies>

</project>

2.服务配置文件application.yml

server:
  port: 7000
spring:
  application:
    name: sm1234-eureka
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://127.0.0.1:$server.port/eureka

3.启动类函数

package cn.sm1234.eureka;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
/**
 * 注册中心微服务
 */
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication 
    public static void main(String[] args) 
        SpringApplication.run(EurekaApplication.class,args);

    

4.启动eureka程序

以上是关于k8s部署微服务springcloud从0-1(Eureka实现)的主要内容,如果未能解决你的问题,请参考以下文章

k8s部署微服务springcloud从0-1(zuul网关的实现)

k8s+SpringCloud全栈技术:在k8s平台部署亿级高并发的SpringCloud项目

docker+k8s+springcloud微服务集群部署实例

SpringCloud微服务电商系统在Kubernetes集群中上线详细教程

spring cloud 微服务 需要service层吗

基于k8s环境的spring-cloud服务发现和调用配置