In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the method of deploying eureka in K8s cluster". In the daily operation, I believe that many people have doubts about the method of deploying eureka in K8s cluster. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "K8s cluster deployment eureka method". Next, please follow the editor to study!
Let's start with the summary.
The basic purpose of K8S is to deploy clusters, but there are also two types of clusters, one is stateless, similar to some ordinary web services, and the other is stateful, kind:statefulSet, similar to kafka,eureka,MySQL. The first two special features come from the fact that they need to register with each other, ip to be stable, and MySQL to be stable. In short, ip needs to be stable, at least internally.
Kind:statefulSet provides this stable mechanism, and the hostname and ip under pod are regular and sequential, rather than random characters like kind:Deployment. By deploying the cluster through statefuleSet, you can know the ip address of each pod in the cluster without starting eureka, and achieve the purpose of registering each other.
PS: failed N times in the middle, because the first contact, always thought that the configuration is wrong, but can not locate the wrong place. After retrying N times by changing the configuration, I found that spring-boot-starter-security was turned on and the password was set in eureka. But I did not configure the password in eureka.client.serviceUrl.defaultZone in the configuration!
PS: verification of the final result: I have created a new service kind:NodePort and acted as an agent. Then download an index.html directly from the wget http://user:password@{NodePortIp}:{port} on the host to check the registration and confirm the OK. (in the face of places that cannot be accessed directly, we can only hit the source code directly.)
If the server ip can be accessed locally, just read it directly through the browser. As for why the request is {port} instead of the defined {NodePort}, I found that {NodePort} can not access, I do not know what went wrong, I am not an operation and maintenance, too late, sleep! Keep your hair tight.
PS: why not use multiple service, one service and one pod... I didn't try this. The main thing I think is that the ip and pod of service are not the same. It seems to be solved by modifying the hostname in application.yml, but in terms of elasticity, it all depends on manual.
Finally, I would like to talk about the practice.
I'm a hand-holding party.
Basically, just refer to this to do it.
The configuration below when https://qingmu.io/2019/08/07/Run-eureka-cluster-on-kubernetes/# is deployed to kubernetes is modified by itself after referencing the blog above.
Pom.xml
It is not all written, because there is a security check, so it is more likely than other ones.
Org.springframework.boot spring-boot-starter-securityapplication.ymlserver: port: ${PORT:8679} logging: level: com: netflix: eureka: registry: errormanagement: endpoints: web: exposure: include: "*" spring: application: name: eurka-server security: user: name: * password: * * eureka: instance: leaseRenewalIntervalInSeconds: 5 leaseExpirationDurationInSeconds: 10 instance-id: ${EUREKA_INSTANCE_HOSTNAME:$ {spring.application.name}}: ${server.port} @ ${random.long (1000000 spring.application.name})} hostname: ${EUREKA_INSTANCE_HOSTNAME:$ {spring.application.name}} client:# register-with-eureka: true# fetch-registry: true registry-fetch-interval-seconds: 5 serviceUrl: defaultZone: ${EUREKA_SERVER: Http://127.0.0.1:${server.port}/eureka/} server: use-read-only-response-cache: false enable-self-preservation: false eviction-interval-timer-in-ms: 500 percent renewal-percent-threshold: 0.1 waitTimeInMsWhenSyncEmpty: 0eureka-statefulSet.yml---apiVersion: v1kind: name: eureka labels: app: eurekaspec: ports:-port: 8769 name: eureka clusterIP: None selector: App: eureka---apiVersion: apps/v1kind: StatefulSetmetadata: name: eurekaspec: serviceName: "eureka" replicas: 3 selector: matchLabels: app: eureka template: metadata: labels: app: eurekaspec: containers:-name: eureka # Image pack eurek yourself image: * ports: -containerPort: 8762 resources: limits: # jvm will automatically discover the restriction memory: 1Gi env:-name: MY_POD_NAME valueFrom: fieldRef: fieldPath: metadata.name-name: JAVA_OPTS value: -XX:+UnlockExperimentalVMOptions-XX:+UseCGroupMemoryLimitForHeap-XX:MaxRAMFraction=2-XX:CICompilerCount=8-XX:ActiveProcessorCount=8-XX:+UseG1GC-XX:+AggressiveOpts-XX:+UseFastAccessorMethods-XX:+UseStringDeduplication-XX:+UseCompressedOops -XX:+OptimizeStringConcat-name: EUREKA_SERVER value: "http://**:****@eureka-0.eureka:8769/eureka/, Http://**:****@eureka-1.eureka:8769/eureka/,http://**:****@eureka-2.eureka:8769/eureka/"-name: EUREKA_INSTANCE_HOSTNAME value: ${MY_POD_NAME} .eureka-name: PORT value: "8769" podManagementPolicy: "Parallel" The study on "the method of deploying eureka in K8s cluster" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.