简体   繁体   English

如何在Kubernetes集群中创建Mediawiki的多个实例

[英]How to create multiple instances of Mediawiki in a Kubernetes Cluster

I´m about to deploy multiple Mediawiki instances on my Kubernetes-cluster. 我将在我的Kubernetes集群上部署多个Mediawiki实例。 In my case the YAML deploymentfile for the DB (MySQL) works as it supposed to do, the deploymentfile for Mediawiki deploys as many pods as expected, but I can´t access them from outside of the cluster even if I create a Service for this case. 在我的情况下,DB(MySQL)的YAML部署文件按预期工作,Mediawiki的部署文件按预期部署了尽可能多的pod,但即使我为此创建服务,我也无法从集群外部访问它们案件。

If I try to create one single Mediawiki pod and a service to access it from outside of the cluster it works as it should. 如果我尝试创建一个单独的Mediawiki pod和一个从群集外部访问它的服务,它就可以正常工作。 If I try to create a deploymentfile for Mediawiki equal to the one for MySQL it does creates the pods and the requiered service but it´s not accessible from the externel-IP assigned to it. 如果我尝试为Mediawiki创建一个等于MySQL的部署文件,它会创建pod和所需的服务,但不能从分配给它的外部IP中访问它。

My deploymentfile for Mediawiki: 我的Mediawiki部署文件:

apiVersion: v1
kind: Service
metadata:
 name: mediawiki-service
 labels:
  name: mediawiki-service
  app: mediawiki
spec:
 type: LoadBalancer
 ports:
 - port: 80
   targetPort: 80
 selector:
  name: mediawiki-pod
  app: mediawiki
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mediawiki
spec:
  replicas: 6
  selector:
    matchLabels:
      app: mediawiki
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mediawiki
    spec:
      containers:
      - image: mediawiki
        name: mediawiki
        ports:
        - containerPort: 80
          name: mediawiki

This is the pod-definition file: 这是pod定义文件:

apiVersion: v1
kind: Pod
metadata:
 name: mediawiki-pod
 labels:
  name: mediawiki-pod
  app: mediawiki
spec:
 containers:
 - name: mediawiki
   image: mediawiki
   ports:
   - containerPort: 80

This is the service-definition file: 这是服务定义文件:

apiVersion: v1
kind: Service
metadata:
 name: mediawiki-service
 labels:
  name: mediawiki-service
  app: mediawiki
spec:
 type: LoadBalancer
 ports:
 - port: 80
   targetPort: 80
 selector:
  name: mediawiki-pod

The accual resault should be that I can deploy multiple instances of Mediawiki on my cluster and can access them from outside with the externel-IP. 准确性应该是我可以在我的集群上部署多个Mediawiki实例,并可以使用外部IP从外部访问它们。

If you want to deploy multiple instances of some piece of software on Kubernetes cluster it's good idea to check out if there is a helm chart for it. 如果你想在Kubernetes集群上部署一些软件的多个实例,最好检查一下是否有一个掌舵图。 In your case the answer is positive - there is a stable helm chart for Mediawiki . 在你的情况下答案是肯定的 - Mediawiki有一个稳定的头盔图表

Creating multiple instances is as easy as creating multiple releases, for example: 创建多个实例就像创建多个版本一样简单,例如:

helm install --name wiki1 stable/mediawiki
helm install --name wiki2 stable/mediawiki
helm install --name wiki3 stable/mediawiki

To use Helm you have to install it on your local machine and on k8s cluster - following the quick start guide will be enough. 要使用Helm,您必须将其安装在本地计算机和k8s群集上 - 按照快速入门指南即可

If you look at kubectl describe service mediawiki-service in both scenarios, I expect you will see that in the single-pod case, there is an Endpoints: list that includes a single IP address (the pod's, but that's an implementation detail) but in the deployment case, it says <none> . 如果你看两个场景中的kubectl describe service mediawiki-service ,我希望你会看到在单pod的情况下,有一个Endpoints: list包含一个IP地址(pod的,但这是一个实现细节)但是在部署案例中,它说<none>

Your Service only matches pods that have both name and app labels: 您的服务仅匹配同时包含nameapp标签的广告连播:

apiVersion: v1
kind: Service
spec:
 selector:
  name: mediawiki-pod
  app: mediawiki

But the pods deployed by your deployment only have app labels: 但部署部署的pod只有app标签:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    metadata:
      labels:
        app: mediawiki

So at that specific point (the labels inside the template for the deployment; also adding them at the top level doesn't hurt, but this embedded point is what's important) you need to add the second label name: mediawiki-pod . 因此,在该特定点(模板内部的标签用于部署;同时在顶层添加它们并没有坏处,但这个嵌入点是重要的)您需要添加第二个标签name: mediawiki-pod

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Windows 上创建具有多个节点的 Kubernetes 集群 - How to create Kubernetes cluster with multiple nodes on Windows 如何为kubernetes集群创建多个管理员用户? - How to create multiple admin users for kubernetes cluster? 我们可以创建 Kubernetes 集群的多个实例并通过不同的外部 IP 访问它吗? - Can we create multiple instances of a Kubernetes cluster & access it through different external IPs? 如何在Kubernetes集群中创建用户? - How to create a user in a Kubernetes cluster? 如何在同一个 kubernetes 集群中部署依赖于数据库的微服务(可能的多个实例)? - How to deploy a microservice ( possible multiple instances) dependent on database in the same kubernetes cluster? AWS EKS NodeGroup“创建失败”:实例未能加入 kubernetes 集群 - AWS EKS NodeGroup "Create failed": Instances failed to join the kubernetes cluster 如何使用Kops或Kubernetes创建AWS竞价型实例? - How to create AWS spot instances with Kops or Kubernetes? 如何在 Docker 桌面上创建一个新的 Kubernetes 集群? - How to create a new Kubernetes cluster on Docker Desktop? 如何使用 kubeadm 创建 kube.netes 集群? - How to use kubeadm to create kubernetes cluster? 如何在没有Kubernetes的情况下使用MQ创建Docker集群 - How to create a docker cluster with MQ without Kubernetes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM