先安装Ingress Controller

安装Ingress Controller后,其他服务设置Ingress后就可以通过设置的域名进行访问了,就不用通过代理的方式或者ip:port的方式进行访问了

安装Ingress Controller

教程地址:https://www.cnblogs.com/sanduzxcvbnm/p/13208837.html

安装Ingress Controller后的效果







几种不同的访问方式

1.通过代理方式访问







2.通过ip:port方式访问





3.通过域名方式访问

因为是在本机进行的测试,需要在本机hosts中添加解析

192.168.75.11 cloud-eureka.hkd.demo.kuboard.cn



改造项目使用的Dockerfile文件

详细地址:https://www.cnblogs.com/sanduzxcvbnm/p/13209058.html

部署eureka

需要采用Statefulsets,不能采用Delpoyments

原因分析:

采用Delpoyments的话,设置三个副本,eureka界面上会显示三个出来

但是会有问题,其他服务无法注册进来

采用Statefulsets的话,设置三个副本,eureka界面上会显示随机显示两个出来,刷新页面,会显示的这俩会随机变动,总之不会显示三个,并且其他服务也能注册进来

步骤选项





部署config



部署gateway







部署auth





eureka,config,gateway,auth效果

其他模块

剩余的其他模块配置差不多都一样,都是在StatefulSet,镜像tag是0.3,都开启了Service,但是没有开启ingress

最终效果





思考:关于模块要不要开启访问方式 Service?要不要开启ingress?

1.Service是必须要开的

因为若关闭的话,有些服务是依赖于其他服务的,假若把config模块的给关了,则gateway模块会因为找不到config而无法启动

关闭后的效果

开启后的效果

2.ingress,这个根据情况而定,这个是给外网访问用的,有些模块需要进行外网访问,比如eureka,有些不需要,那么只给有需要的开启,没需要的就不开启

导出工作负载

地址:https://files.cnblogs.com/files/sanduzxcvbnm/kuboard_hkd_20200630093006.7z

文件内容:


---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: hkd
name: cloud-config
annotations:
k8s.kuboard.cn/workload: cloud-config
k8s.kuboard.cn/displayName: 配置中心
k8s.kuboard.cn/ingress: 'false'
k8s.kuboard.cn/service: NodePort
labels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-config
spec:
selector:
matchLabels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-config
revisionHistoryLimit: 10
template:
metadata:
labels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-config
spec:
securityContext:
seLinuxOptions: {}
imagePullSecrets:
- name: nexus
restartPolicy: Always
initContainers: []
containers:
- image: 'idocker.io/hkd-config:0.3'
imagePullPolicy: Always
name: hkd-config
volumeMounts: []
resources:
limits:
requests:
env: []
envFrom:
- configMapRef:
name: eureka-config
lifecycle: {}
volumes: []
dnsPolicy: ClusterFirst
dnsConfig: {}
nodeName: worker
terminationGracePeriodSeconds: 30
replicas: 1
volumeClaimTemplates: []
serviceName: cloud-config ---
apiVersion: v1
kind: Service
metadata:
namespace: hkd
name: cloud-config
annotations:
k8s.kuboard.cn/workload: cloud-config
k8s.kuboard.cn/displayName: 配置中心
labels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-config
spec:
selector:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-config
type: NodePort
ports:
- port: 8888
targetPort: 8888
protocol: TCP
name: msbf6b
nodePort: 30886 ---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: hkd
name: cloud-eureka
annotations:
k8s.kuboard.cn/workload: cloud-eureka
k8s.kuboard.cn/displayName: 服务注册中心
k8s.kuboard.cn/ingress: 'true'
k8s.kuboard.cn/service: NodePort
labels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-eureka
spec:
selector:
matchLabels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-eureka
revisionHistoryLimit: 10
template:
metadata:
labels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-eureka
spec:
securityContext:
seLinuxOptions: {}
imagePullSecrets:
- name: nexus
restartPolicy: Always
initContainers: []
containers:
- image: 'idocker.io/hkd-eureka:0.3'
imagePullPolicy: Always
name: eureka-server
volumeMounts: []
resources:
limits:
requests:
env: []
envFrom:
- configMapRef:
name: eureka-config
lifecycle: {}
volumes: []
dnsPolicy: ClusterFirst
dnsConfig: {}
terminationGracePeriodSeconds: 30
replicas: 3
volumeClaimTemplates: []
serviceName: cloud-eureka ---
apiVersion: v1
kind: Service
metadata:
namespace: hkd
name: cloud-eureka
annotations:
k8s.kuboard.cn/workload: cloud-eureka
k8s.kuboard.cn/displayName: 服务注册中心
labels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-eureka
spec:
selector:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-eureka
type: NodePort
ports:
- port: 8761
targetPort: 8761
protocol: TCP
name: siwrzh
nodePort: 30242 ---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
namespace: hkd
name: cloud-eureka
annotations:
k8s.kuboard.cn/workload: cloud-eureka
k8s.kuboard.cn/displayName: 服务注册中心
labels:
k8s.kuboard.cn/layer: cloud
k8s.kuboard.cn/name: cloud-eureka
spec:
rules:
- host: cloud-eureka.hkd.demo.kuboard.cn
http:
paths:
- path: /
backend:
serviceName: cloud-eureka
servicePort: siwrzh ---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: hkd
name: gateway-gw2
annotations:
k8s.kuboard.cn/workload: gateway-gw2
k8s.kuboard.cn/displayName: 网关中心
k8s.kuboard.cn/ingress: 'true'
k8s.kuboard.cn/service: NodePort
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: gateway-gw2
spec:
selector:
matchLabels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: gateway-gw2
revisionHistoryLimit: 10
template:
metadata:
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: gateway-gw2
spec:
securityContext:
seLinuxOptions: {}
imagePullSecrets:
- name: nexus
restartPolicy: Always
initContainers: []
containers:
- image: 'idocker.io/hkd-gateway:0.3'
imagePullPolicy: Always
name: hkd-gateway
volumeMounts: []
resources:
limits:
requests:
env: []
envFrom:
- configMapRef:
name: eureka-config
lifecycle: {}
volumes: []
dnsPolicy: ClusterFirst
dnsConfig: {}
terminationGracePeriodSeconds: 30
replicas: 1
volumeClaimTemplates: []
serviceName: gateway-gw2 ---
apiVersion: v1
kind: Service
metadata:
namespace: hkd
name: gateway-gw2
annotations:
k8s.kuboard.cn/workload: gateway-gw2
k8s.kuboard.cn/displayName: 网关中心
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: gateway-gw2
spec:
selector:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: gateway-gw2
type: NodePort
ports:
- port: 5000
targetPort: 5000
protocol: TCP
name: m6ykbh
nodePort: 31646 ---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
namespace: hkd
name: gateway-gw2
annotations:
k8s.kuboard.cn/workload: gateway-gw2
k8s.kuboard.cn/displayName: 网关中心
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: gateway-gw2
spec:
rules:
- host: gwateway-gw2.hkd.demo.kuboard.cn
http:
paths:
- path: /
backend:
serviceName: gateway-gw2
servicePort: m6ykbh ---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: hkd
name: svc-auth
annotations:
k8s.kuboard.cn/workload: svc-auth
k8s.kuboard.cn/displayName: 验证中心
k8s.kuboard.cn/ingress: 'false'
k8s.kuboard.cn/service: NodePort
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-auth
spec:
selector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-auth
revisionHistoryLimit: 10
template:
metadata:
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-auth
spec:
securityContext:
seLinuxOptions: {}
imagePullSecrets:
- name: nexus
restartPolicy: Always
initContainers: []
containers:
- image: 'idocker.io/hkd-auth:0.3'
imagePullPolicy: Always
name: hkd-auth
volumeMounts: []
resources:
limits:
requests:
env: []
envFrom:
- configMapRef:
name: eureka-config
lifecycle: {}
volumes: []
dnsPolicy: ClusterFirst
dnsConfig: {}
terminationGracePeriodSeconds: 30
replicas: 1
volumeClaimTemplates: []
serviceName: svc-auth ---
apiVersion: v1
kind: Service
metadata:
namespace: hkd
name: svc-auth
annotations:
k8s.kuboard.cn/workload: svc-auth
k8s.kuboard.cn/displayName: 验证中心
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-auth
spec:
selector:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-auth
type: NodePort
ports:
- port: 8765
targetPort: 8765
protocol: TCP
name: wjn5hh
nodePort: 32443 ---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: hkd
name: svc-cash
annotations:
k8s.kuboard.cn/workload: svc-cash
k8s.kuboard.cn/ingress: 'false'
k8s.kuboard.cn/service: NodePort
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-cash
spec:
selector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-cash
revisionHistoryLimit: 10
template:
metadata:
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-cash
spec:
securityContext:
seLinuxOptions: {}
imagePullSecrets:
- name: nexus
restartPolicy: Always
initContainers: []
containers:
- image: 'idocker.io/hkd-cash:0.3'
imagePullPolicy: Always
name: hkd-cash
volumeMounts: []
resources:
limits:
requests:
env: []
envFrom:
- configMapRef:
name: eureka-config
lifecycle: {}
volumes: []
dnsPolicy: ClusterFirst
dnsConfig: {}
terminationGracePeriodSeconds: 30
replicas: 1
volumeClaimTemplates: []
serviceName: svc-cash ---
apiVersion: v1
kind: Service
metadata:
namespace: hkd
name: svc-cash
annotations:
k8s.kuboard.cn/workload: svc-cash
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-cash
spec:
selector:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-cash
type: NodePort
ports:
- port: 8766
targetPort: 8766
protocol: TCP
name: kfcdez
nodePort: 31091 ---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: hkd
name: svc-custom
annotations:
k8s.kuboard.cn/workload: svc-custom
k8s.kuboard.cn/ingress: 'false'
k8s.kuboard.cn/service: NodePort
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-custom
spec:
selector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-custom
revisionHistoryLimit: 10
template:
metadata:
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-custom
spec:
securityContext:
seLinuxOptions: {}
imagePullSecrets:
- name: nexus
restartPolicy: Always
initContainers: []
containers:
- image: 'idocker.io/hkd-custom:0.3'
imagePullPolicy: Always
name: hkd-custom
volumeMounts: []
resources:
limits:
requests:
env: []
envFrom:
- configMapRef:
name: eureka-config
lifecycle: {}
volumes: []
dnsPolicy: ClusterFirst
dnsConfig: {}
terminationGracePeriodSeconds: 30
replicas: 1
volumeClaimTemplates: []
serviceName: svc-custom ---
apiVersion: v1
kind: Service
metadata:
namespace: hkd
name: svc-custom
annotations:
k8s.kuboard.cn/workload: svc-custom
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-custom
spec:
selector:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-custom
type: NodePort
ports:
- port: 8764
targetPort: 8764
protocol: TCP
name: e82zsm
nodePort: 32733 ---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: hkd
name: svc-portal
annotations:
k8s.kuboard.cn/workload: svc-portal
k8s.kuboard.cn/ingress: 'false'
k8s.kuboard.cn/service: NodePort
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-portal
spec:
selector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-portal
revisionHistoryLimit: 10
template:
metadata:
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-portal
spec:
securityContext:
seLinuxOptions: {}
imagePullSecrets:
- name: nexus
restartPolicy: Always
initContainers: []
containers:
- image: 'idocker.io/hkd-portal:0.3'
imagePullPolicy: Always
name: hkd-portal
volumeMounts: []
resources:
limits:
requests:
env: []
envFrom:
- configMapRef:
name: eureka-config
lifecycle: {}
volumes: []
dnsPolicy: ClusterFirst
dnsConfig: {}
terminationGracePeriodSeconds: 30
replicas: 1
volumeClaimTemplates: []
serviceName: svc-portal ---
apiVersion: v1
kind: Service
metadata:
namespace: hkd
name: svc-portal
annotations:
k8s.kuboard.cn/workload: svc-portal
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-portal
spec:
selector:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-portal
type: NodePort
ports:
- port: 8767
targetPort: 8767
protocol: TCP
name: sbwmf2
nodePort: 31346 ---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: hkd
name: svc-user
annotations:
k8s.kuboard.cn/workload: svc-user
k8s.kuboard.cn/displayName: 用户
k8s.kuboard.cn/ingress: 'false'
k8s.kuboard.cn/service: NodePort
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-user
spec:
selector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-user
revisionHistoryLimit: 10
template:
metadata:
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-user
spec:
securityContext:
seLinuxOptions: {}
imagePullSecrets:
- name: nexus
restartPolicy: Always
initContainers: []
containers:
- image: 'idocker.io/hkd-user:0.3'
imagePullPolicy: Always
name: hkd-user
volumeMounts: []
resources:
limits:
requests:
env: []
envFrom:
- configMapRef:
name: eureka-config
lifecycle: {}
volumes: []
dnsPolicy: ClusterFirst
dnsConfig: {}
terminationGracePeriodSeconds: 30
replicas: 1
volumeClaimTemplates: []
serviceName: svc-user ---
apiVersion: v1
kind: Service
metadata:
namespace: hkd
name: svc-user
annotations:
k8s.kuboard.cn/workload: svc-user
k8s.kuboard.cn/displayName: 用户
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-user
spec:
selector:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: svc-user
type: NodePort
ports:
- port: 8763
targetPort: 8763
protocol: TCP
name: s5egas
nodePort: 30083 ---
metadata:
name: eureka-config
namespace: hkd
managedFields:
- manager: Mozilla
operation: Update
apiVersion: v1
time: '2020-06-29T01:44:36Z'
fieldsType: FieldsV1
fieldsV1:
'f:data':
.: {}
'f:eureka.client.serviceUrl.defaultZone': {}
'f:eureka.instance.prefer-ip-address': {}
data:
eureka.client.serviceUrl.defaultZone: >-
http://cloud-eureka-0.cloud-eureka.hkd.svc.cluster.local:8761/eureka,http://cloud-eureka-1.cloud-eureka.hkd.svc.cluster.local:8761/eureka,http://cloud-eureka-2.cloud-eureka.hkd.svc.cluster.local:8761/eureka
eureka.instance.prefer-ip-address: 'false'
kind: ConfigMap
apiVersion: v1 ---
metadata:
name: nexus
namespace: hkd
managedFields:
- manager: Mozilla
operation: Update
apiVersion: v1
time: '2020-06-28T07:45:21Z'
fieldsType: FieldsV1
fieldsV1:
'f:data':
.: {}
'f:.dockerconfigjson': {}
'f:type': {}
data:
.dockerconfigjson: >-
eyJhdXRocyI6eyJodHRwczovL2lkb2NrZXIuaW8iOnsidXNlcm5hbWUiOiJhZG1pbiIsInBhc3N3b3JkIjoibmV3bm9kZTc4NTIiLCJhdXRoIjoiWVdSdGFXNDZibVYzYm05a1pUYzROVEk9In19fQ==
type: kubernetes.io/dockerconfigjson
kind: Secret
apiVersion: v1

使用Kuboard界面在k8s上部署SpringCloud项目的更多相关文章

  1. 优化:在k8s上部署的gitlab

    gitlab组件图 gitlab在k8s上占用资源 # kubectl top pods -n default | grep git* gitlab-gitaly-0 9m 444Mi gitlab- ...

  2. kubernetes之三 使用kubectl在k8s上部署应用

    在上一篇中,我们学习了使用minikube来搭建k8s集群.k8s集群启动后,就可以在上面部署应用了.本篇,我们就来学习如何使用kubectl在k8s上部署应用. 学习之前,可以先从下面这篇博客上了解 ...

  3. 在k8s上部署日志系统elfk

    日志系统elfk 前言 经过上周的技术预研,在本周一通过开会研究,根据公司的现有业务流量和技术栈,决定选择的日志系统方案为:elasticsearch(es)+logstash(lo)+filebea ...

  4. 使用Rancher在K8S上部署高性能PHP应用程序

    介 绍 PHP是网络上最流行的编程语言之一,许多被广泛使用的内容管理系统都使用它开发,如WordPress和Drupal,并为现代服务器端框架(如Laravel和Symfony)提供核心代码. 尽管P ...

  5. docker初体验:Docker部署SpringCloud项目eureka-server

    Docker部署SpringCloud项目eureka-server 1 创建eureka-server工程 创建父工程cloud-demo,其pom.xml如下: <?xml version= ...

  6. 在nginx上部署vue项目(history模式);

    在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...

  7. 在Linux上部署Web项目

    You believe it or not there is a feeling, lifetime all not lost to time. 在Linux上部署Web项目 这个是普通的web项目, ...

  8. 在nginx上部署vue项目(history模式)--demo实列;

    在很早之前,我写了一篇 关于 在nginx上部署vue项目(history模式) 但是讲的都是理论,所以今天做个demo来实战下.有必要让大家更好的理解,我发现搜索这类似的问题还是挺多的,因此在写一篇 ...

  9. 新手小白在github上部署一个项目

    新手小白在github上部署一个项目 一. 注册github账号 github地址:https://www.github.com/ 二.下载安装Git 地址:https://git-scm.com/d ...

随机推荐

  1. Menci的序列

    题目大意 一个长度为n的字符串s,只包含+和×. 选出一个子序列,然后你有一个ret,初始为0,按顺序扫你选出的这个子序列. 如果碰到的是+,ret+1,否则ret*2. 最大化ret%2^k. 首先 ...

  2. 可变参数和Collections集合工具类

    可变参数 /** * 可变参数:jdk1.5后出现的新特性 * 使用前期: * 当方法的参数列表数据类型已经确定的时候但是参数的个数不确定的时候就可以使用可变参数 * 使用格式:定义方法的时候使用 * ...

  3. TFRecord的Shuffle、划分和读取

    对数据集的shuffle处理需要设置相应的buffer_size参数,相当于需要将相应数目的样本读入内存,且这部分内存会在训练过程中一直保持占用.完全的shuffle需要将整个数据集读入内存,这在大规 ...

  4. React报错之组件不能作为JSX组件使用

    正文从这开始~ 总览 组件不能作为JSX组件使用,出现该错误有多个原因: 返回JSX元素数组,而不是单个元素. 从组件中返回JSX元素或者null以外的任何值. 使用过时的React类型声明. 返回单 ...

  5. linux 文件存放目录

    Linux不靠文件扩展名区分文件类型(windous病毒和木马不能在linux里面运行) 所有的存储设备都必须挂载之后才能使用(包括硬盘,U盘和光盘),例如给它手工给它分配盘符 Linux所有内容以文 ...

  6. 智慧文旅IOC大数据可视化建设方案

    一.建设背景 自2020年以来,疫情对各行各业的都造成了不同程度的影响,对依赖人口消费实现商业价值的文旅行业更是受到了更大的冲击,因此在疫情当下以及科技发达的今天,如何利用科技的手段赋能文旅行业进行数 ...

  7. 万答#19,MySQL可以禁用MyISAM引擎吗?

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. MyISAM的适用场景越来越少了. 随着MySQL 8.0的推出,系统表已经全面采用InnoDB引擎,不再需要MyISAM ...

  8. Go语言 context包源码学习

    你必须非常努力,才能看起来毫不费力! 微信搜索公众号[ 漫漫Coding路 ],一起From Zero To Hero ! 前言 日常 Go 开发中,Context 包是用的最多的一个了,几乎所有函数 ...

  9. 创新能力加速产业发展,SphereEx 荣获“中关村银行杯”『大数据与云计算』领域 TOP1

    8 月 9 日下午,2022 中关村国际前沿科技创新大赛"中关村银行杯"大数据与云计算领域决赛在北京市门头沟区中关村(京西)人工智能科技园·智能文创园落下了帷幕.SphereEx ...

  10. Java SE 13 新增特性

    Java SE 13 新增特性 作者:Grey 原文地址:Java SE 13 新增特性 源码 源仓库: Github:java_new_features 镜像仓库: GitCode:java_new ...