编写 activemq.yaml 文件 v1
apiVersion: v1
kind: Service
metadata:
name: nodeport-activemq
namespace: default
spec:
selector:
app: activemq
ports:
- port: 8161
targetPort: 8161
protocol: TCP
name: admin
nodePort: 30001
- port: 61616
targetPort: 61616
protocol: TCP
name: tcp
nodePort: 30002
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-activemq
namespace: default
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
v2版本,设置密码
apiVersion: v1
kind: Service
metadata:
name: nodeport-activemq
namespace: default
spec:
selector:
app: activemq
ports:
- port: 8161
targetPort: 8161
protocol: TCP
name: admin
nodePort: 30001
- port: 61616
targetPort: 61616
protocol: TCP
name: tcp
nodePort: 30002
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-activemq
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: activemq
template:
metadata:
labels:
app: activemq
spec:
containers:
- name: activemq
image: webcenter/activemq:latest
ports:
- containerPort: 61616
name: tcp
- containerPort: 8161
name: admin
env:
- name: ACTIVEMQ_ADMIN_LOGIN
value: admin
- name: ACTIVEMQ_ADMIN_PASSWORD
value: xxxxxx
namespace : 按实际情况填写命名空间
nodePort :映射端口不填则随机分配,上文把 61616 映射到 30005,把 8161 映射到 30004
61616:为对外服务端口号
8161:为控制器端口号
执行 yaml
kubectl apply -f create_activemq.yaml
总结
对外端口 一定要在 30000-32767之间