diff --git a/.vuepress/config-sidebar.js b/.vuepress/config-sidebar.js index b42ecac..0765cf0 100644 --- a/.vuepress/config-sidebar.js +++ b/.vuepress/config-sidebar.js @@ -410,7 +410,15 @@ let sidebar = { children: [ 'k8s-advanced/ts/application', 'k8s-advanced/ts/cluster', - 'k8s-advanced/ts/deployment' + 'k8s-advanced/ts/deployment', + { + title: 'KuboardProxy', + collapsable: true, + children: [ + 'k8s-advanced/proxy/', + 'k8s-advanced/proxy/rebase', + ] + } ] }, { @@ -503,6 +511,7 @@ let sidebar = { title: '实战', collapsable: true, children: [ + 'k8s-practice/import/import', 'k8s-practice/gpu/gpu', 'k8s-practice/access/port-forward', 'k8s-practice/admin/list-images', diff --git a/.vuepress/public/kuboard_example_v3.yaml b/.vuepress/public/kuboard_example_v3.yaml new file mode 100644 index 0000000..e0bd830 --- /dev/null +++ b/.vuepress/public/kuboard_example_v3.yaml @@ -0,0 +1,363 @@ + +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + namespace: example + name: cloud-eureka + annotations: + k8s.kuboard.cn/workload: cloud-eureka + k8s.kuboard.cn/displayName: 服务注册 + k8s.kuboard.cn/service: ClusterIP + k8s.kuboard.cn/ingress: 'true' + 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 + template: + metadata: + labels: + k8s.kuboard.cn/layer: cloud + k8s.kuboard.cn/name: cloud-eureka + spec: + imagePullSecrets: + - {} + initContainers: [] + containers: + - image: 'swr.cn-east-2.myhuaweicloud.com/kuboard-dependency/example-cloud-eureka:v1.0.0-alpha.1' + imagePullPolicy: Always + name: cloud-eureka + volumeMounts: [] + resources: {} + env: + - name: CLOUD_EUREKA_DEFAULT_ZONE + value: 'http://cloud-eureka-0:9200/eureka' + volumes: [] + replicas: 1 + volumeClaimTemplates: [] + serviceName: cloud-eureka + +--- +apiVersion: v1 +kind: Service +metadata: + namespace: example + 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: ClusterIP + ports: + - port: 9200 + targetPort: 9200 + protocol: TCP + name: mtfsyi + nodePort: 0 + +--- +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + namespace: example + 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.example.demo.kuboard.cn + http: + paths: + - path: / + backend: + serviceName: cloud-eureka + servicePort: mtfsyi + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: example + name: db-example + annotations: + k8s.kuboard.cn/workload: db-example + k8s.kuboard.cn/displayName: db-example + k8s.kuboard.cn/service: ClusterIP + k8s.kuboard.cn/ingress: 'false' + labels: + k8s.kuboard.cn/layer: db + k8s.kuboard.cn/name: db-example +spec: + selector: + matchLabels: + k8s.kuboard.cn/layer: db + k8s.kuboard.cn/name: db-example + template: + metadata: + labels: + k8s.kuboard.cn/layer: db + k8s.kuboard.cn/name: db-example + spec: + imagePullSecrets: + - {} + initContainers: [] + containers: + - image: 'swr.cn-east-2.myhuaweicloud.com/kuboard-dependency/example-db-example:v1.0.0-alpha.1' + imagePullPolicy: Always + name: db-example + volumeMounts: + - name: db-example-storage + mountPath: /var/lib/mysql + subPath: mysql + resources: {} + env: + - name: MYSQL_ROOT_PASSWORD + value: 'soqjdke4#es' + volumes: + - name: db-example-storage + persistentVolumeClaim: + claimName: db-example-storage + replicas: 1 + +--- +apiVersion: v1 +kind: Service +metadata: + namespace: example + name: db-example + annotations: + k8s.kuboard.cn/workload: db-example + k8s.kuboard.cn/displayName: db-example + labels: + k8s.kuboard.cn/layer: db + k8s.kuboard.cn/name: db-example +spec: + selector: + k8s.kuboard.cn/layer: db + k8s.kuboard.cn/name: db-example + type: ClusterIP + ports: + - port: 3306 + targetPort: 3306 + protocol: TCP + name: fp6ksw + nodePort: 0 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: example + name: gateway-example + annotations: + k8s.kuboard.cn/workload: gateway-example + k8s.kuboard.cn/displayName: gateway-example + k8s.kuboard.cn/service: ClusterIP + k8s.kuboard.cn/ingress: 'false' + labels: + k8s.kuboard.cn/layer: gateway + k8s.kuboard.cn/name: gateway-example +spec: + selector: + matchLabels: + k8s.kuboard.cn/layer: gateway + k8s.kuboard.cn/name: gateway-example + template: + metadata: + labels: + k8s.kuboard.cn/layer: gateway + k8s.kuboard.cn/name: gateway-example + spec: + imagePullSecrets: + - {} + initContainers: [] + containers: + - image: 'swr.cn-east-2.myhuaweicloud.com/kuboard-dependency/example-gateway-example:v1.0.0-alpha.1' + imagePullPolicy: Always + name: gateway-example + volumeMounts: [] + resources: {} + env: + - name: CLOUD_EUREKA_DEFAULT_ZONE + value: 'http://cloud-eureka:9200/eureka' + - name: SPRING_PROFILES_ACTIVE + value: example + volumes: [] + replicas: 1 + +--- +apiVersion: v1 +kind: Service +metadata: + namespace: example + name: gateway-example + annotations: + k8s.kuboard.cn/workload: gateway-example + k8s.kuboard.cn/displayName: gateway-example + labels: + k8s.kuboard.cn/layer: gateway + k8s.kuboard.cn/name: gateway-example +spec: + selector: + k8s.kuboard.cn/layer: gateway + k8s.kuboard.cn/name: gateway-example + type: ClusterIP + ports: + - port: 9201 + targetPort: 9201 + protocol: TCP + name: pdmd3y + nodePort: 0 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: example + name: svc-example + annotations: + k8s.kuboard.cn/workload: svc-example + k8s.kuboard.cn/displayName: svc-example + k8s.kuboard.cn/service: none + k8s.kuboard.cn/ingress: 'false' + labels: + k8s.kuboard.cn/layer: svc + k8s.kuboard.cn/name: svc-example +spec: + selector: + matchLabels: + k8s.kuboard.cn/layer: svc + k8s.kuboard.cn/name: svc-example + template: + metadata: + labels: + k8s.kuboard.cn/layer: svc + k8s.kuboard.cn/name: svc-example + spec: + imagePullSecrets: + - {} + initContainers: [] + containers: + - image: 'swr.cn-east-2.myhuaweicloud.com/kuboard-dependency/example-svc-example:v1.0.0-alpha.1' + imagePullPolicy: Always + name: svc-example + volumeMounts: [] + resources: {} + env: + - name: CLOUD_EUREKA_DEFAULT_ZONE + value: 'http://cloud-eureka:9200/eureka' + - name: DB_EXAMPLE_URL + value: >- + jdbc:mysql://db-example:3306/eip_db_example?characterEncoding=utf8&useSSL=false + - name: DB_EXAMPLE_USERNAME + value: eip_user + - name: DB_EXAMPLE_PASSWORD + value: 1qaz2wsx + - name: snowflake.dataCenterId + value: '1' + - name: csp.sentinel.dashboard.server + value: monitor-sentinel + volumes: [] + replicas: 1 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: example + name: web-example + annotations: + k8s.kuboard.cn/workload: web-example + k8s.kuboard.cn/displayName: web-example + k8s.kuboard.cn/service: ClusterIP + k8s.kuboard.cn/ingress: 'true' + labels: + k8s.kuboard.cn/layer: web + k8s.kuboard.cn/name: web-example +spec: + selector: + matchLabels: + k8s.kuboard.cn/layer: web + k8s.kuboard.cn/name: web-example + template: + metadata: + labels: + k8s.kuboard.cn/layer: web + k8s.kuboard.cn/name: web-example + spec: + imagePullSecrets: + - {} + initContainers: [] + containers: + - command: + - nginx + - '-g' + - daemon off; + image: 'swr.cn-east-2.myhuaweicloud.com/kuboard-dependency/example-web-example:v1.0.0-alpha.1' + imagePullPolicy: Always + name: web-example + volumeMounts: [] + resources: {} + env: [] + volumes: [] + replicas: 1 + +--- +apiVersion: v1 +kind: Service +metadata: + namespace: example + name: web-example + annotations: + k8s.kuboard.cn/workload: web-example + k8s.kuboard.cn/displayName: web-example + labels: + k8s.kuboard.cn/layer: web + k8s.kuboard.cn/name: web-example +spec: + ports: + - name: mawfrp + nodePort: 30090 + port: 80 + protocol: TCP + targetPort: 80 + selector: + k8s.kuboard.cn/layer: web + k8s.kuboard.cn/name: web-example + type: NodePort + +--- +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + namespace: example + name: web-example + annotations: + k8s.kuboard.cn/workload: web-example + k8s.kuboard.cn/displayName: we-example + labels: + k8s.kuboard.cn/layer: web + k8s.kuboard.cn/name: web-example +spec: + rules: + - host: web-example.example.demo.kuboard.cn + http: + paths: + - path: / + backend: + serviceName: web-example + servicePort: mawfrp diff --git a/learning/k8s-practice/import/import.assets/import-01-create-ns.png b/learning/k8s-practice/import/import.assets/import-01-create-ns.png new file mode 100644 index 0000000..49a3571 Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-01-create-ns.png differ diff --git a/learning/k8s-practice/import/import.assets/import-02-import-page.png b/learning/k8s-practice/import/import.assets/import-02-import-page.png new file mode 100644 index 0000000..cc4929b Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-02-import-page.png differ diff --git a/learning/k8s-practice/import/import.assets/import-03-upload.png b/learning/k8s-practice/import/import.assets/import-03-upload.png new file mode 100644 index 0000000..5c7e65a Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-03-upload.png differ diff --git a/learning/k8s-practice/import/import.assets/import-04-select.png b/learning/k8s-practice/import/import.assets/import-04-select.png new file mode 100644 index 0000000..2685ee0 Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-04-select.png differ diff --git a/learning/k8s-practice/import/import.assets/import-05-pvc.png b/learning/k8s-practice/import/import.assets/import-05-pvc.png new file mode 100644 index 0000000..0cac7f3 Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-05-pvc.png differ diff --git a/learning/k8s-practice/import/import.assets/import-06-nodeport.png b/learning/k8s-practice/import/import.assets/import-06-nodeport.png new file mode 100644 index 0000000..8b3dfc3 Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-06-nodeport.png differ diff --git a/learning/k8s-practice/import/import.assets/import-07-ingress.png b/learning/k8s-practice/import/import.assets/import-07-ingress.png new file mode 100644 index 0000000..db058a2 Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-07-ingress.png differ diff --git a/learning/k8s-practice/import/import.assets/import-08-confirm.png b/learning/k8s-practice/import/import.assets/import-08-confirm.png new file mode 100644 index 0000000..a1592ad Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-08-confirm.png differ diff --git a/learning/k8s-practice/import/import.assets/import-09-ok.png b/learning/k8s-practice/import/import.assets/import-09-ok.png new file mode 100644 index 0000000..cc6db1f Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-09-ok.png differ diff --git a/learning/k8s-practice/import/import.assets/import-10-ns.png b/learning/k8s-practice/import/import.assets/import-10-ns.png new file mode 100644 index 0000000..19a009b Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-10-ns.png differ diff --git a/learning/k8s-practice/import/import.assets/import-11-nodeport.png b/learning/k8s-practice/import/import.assets/import-11-nodeport.png new file mode 100644 index 0000000..6ad49cc Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-11-nodeport.png differ diff --git a/learning/k8s-practice/import/import.assets/import-12-web.png b/learning/k8s-practice/import/import.assets/import-12-web.png new file mode 100644 index 0000000..0f7eb03 Binary files /dev/null and b/learning/k8s-practice/import/import.assets/import-12-web.png differ diff --git a/learning/k8s-practice/import/import.md b/learning/k8s-practice/import/import.md new file mode 100644 index 0000000..c8bc892 --- /dev/null +++ b/learning/k8s-practice/import/import.md @@ -0,0 +1,122 @@ +--- +layout: LearningLayout +description: 通过Kuboard将一个预先定义好的SpringCloud微服务样例程序导入到Kubernetes中。 +--- + +# 导入 example 微服务 + + + +## 前提 + +必须具备如下条件: + +* Kubernetes 集群 +* 导入 example 微服务时,要求 Kubernetes 集群版本不低于 1.14.0 重要 +* 已经安装 [Kuboard v3](/install/v3/install.html) +* 集群中存在有效的存储类,如果没有请参考 [创建存储类](/learning/k8s-intermediate/persistent/nfs.html#在kuboard中创建-nfs-存储类) + +## 创建名称空间 + +创建新的名称空间,用来导入 example。在 Kuboard 的集群页面菜单中,导航到 `名称空间-选择` 菜单,如图所示: + +![创建名称空间](./import.assets/import-01-create-ns.png) + + + +## 导入 example + +* 下载 kuboard_example.yaml 文件 + +* 在完成 `example` 名称空间的创建以后,导航到菜单项 `名称空间` --> `example` --> `常用操作` --> `导入工作负载`,如下图所示: + + ![Kubernetes教程:在Kuboard中导入工作负载](./import.assets/import-02-import-page.png) + +* 点击 ***上传文件*** 按钮 + + 并选择刚才下载的 `kuboard_example.yaml` 文件,如下图所示: + + * 图中将标注此文件中可导入对象的类型及个数; + * `依赖镜像` 中的 `替换镜像标签` 选项,可以方便您在离线环境下进行导入。 + + ![Kubernetes教程:在Kuboard中导入工作负载-上传文件](./import.assets/import-03-upload.png) + +* 点击 ***下一步*** + + 默认选择所有的工作负载,如下图所示: + + ![Kubernetes教程:在Kuboard中导入工作负载-选择所有工作负载](./import.assets/import-04-select.png) + +* 点击 ***下一步*** + + 为存储卷声明 `db-example-storage` 选择合适的存储类,如下图所示: + + | 字段名称 | 填写内容 | 说明 | + | ------------------ | ------------------ | ------------------------------------------------------------ | + | 数据卷类型 | db-example-storage | NFS:容器组直连NFS
存储卷声明:容器组使用存储卷声明 | + | 是否新建存储卷声明 | 创建新存储卷声明 | 使用已有存储卷声明:可以使用事先创建好的存储卷声明
创建新存储卷声明:可以创建新存储卷声明 | + | 分配模式 | 动态分配 | | + | 读写模式 | 可被多节点读写 | 只能被单节点读写、可被多节点只读、可被多节点读写 | + | 总量 | 2Gi | 2Gi代表 2G空间 | + + ![Kubernetes教程:在Kuboard中导入工作负载-选择要存储类](./import.assets/import-05-pvc.png) + +* 点击 ***下一步*** + + 默认没有需要调整的 NodePort + + ![Kubernetes教程:在Kuboard中导入工作负载-选择所有Secrets](./import.assets/import-06-nodeport.png) + +* 点击 ***下一步*** + + 填写新的 Ingress 域名,如下图所示: + + | 字段名称 | 填写内容 | 说明 | + | ---------------- | ---------------------------------- | ------------------------------------------------------------ | + | cloud-eureka域名 | cloud-eureka.example.demo.kuboard.cn | 使用您自己的域名,
在测试环境建议使用如下域名格式:
workloadname.namespace-name.cluster-name.domain.com
该域名应该解析到您worker节点的外网地址,或者worker 节点 80/443 端口对应负载均衡服务器的外网地址。 | + | web-example | web-example.example.demo.eip | | + + ![Kubernetes教程:在Kuboard中导入工作负载-填写存储卷声明参数](./import.assets/import-07-ingress.png) + + +* 点击 ***下一步*** + + ![Kubernetes教程:在Kuboard中导入工作负载-核对信息](./import.assets/import-08-confirm.png) + + + +* 点击 ***确定*** + + ![Kubernetes教程:在Kuboard中导入工作负载-确定](./import.assets/import-09-ok.png) + +* 完成导入 + + 在界面提示下,点击 ***应用***、 ***确定***,完成 `example` 应用的最终导入。 + +* 点击 ***已完成*** + + 可在名称空间概览页中查看到刚才导入的 example 的所有工作负载,如下图所示: + + ![Kubernetes教程:在Kuboard中导入工作负载-查看导入结果](./import.assets/import-10-ns.png) + + + + + +## 验证 web-example + +* 点击工作负载 ***web-example*** + + 切换到 ***服务*** 标签页,可以看到该服务公布了 30090 这个节点端口,如下图所示: + + ![Kubernetes教程:在Kuboard中导入工作负载-查看导入的web-example](./import.assets/import-11-nodeport.png) + + +* 在浏览器地址栏中输入 `http://任意节点IP:30090`,将打开如下页面: + + **Example 部署成功** + +![Kubernetes教程:在Kuboard中导入工作负载-查看日志](./import.assets/import-12-web.png) + + +::tada:: ::tada:: ::tada:: \ No newline at end of file