编写 value.yaml 文件

apiVersion: v1
kind: Service
metadata:
 name: nodeport-activemq
 namespace: component
spec:
 selector:
  app: activemq
 ports:
  - port: 8161
    targetPort: 8161
    protocol: TCP
    name: admin
    nodePort: 30004   
  - port: 61616
    targetPort: 61616
    protocol: TCP
    name: tcp
    nodePort: 30005   
 type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
 name: deploy-activemq
 namespace: component
spec:
 replicas: 1
 selector:
  matchLabels:
    app: activemq
 template:
  metadata:
    labels:
     app: activemq
  spec:
   containers:
    - name: activemq
      image: webcenter/activemq
      ports:
       - containerPort: 8161
         protocol: TCP
       - containerPort: 61616
         protocol: TCP

namespace : 按实际情况填写命名空间
nodePort :映射端口不填则随机分配,上文把 61616 映射到 30005,把 8161 映射到 30004
61616:为对外服务端口号
8161:为控制器端口号

执行 yaml

 kubectl apply -f value.yaml

在这里插入图片描述

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐