2022-12-29:nsq是go语言写的消息队列。请问k3s部署nsq,yaml如何写?

2022-12-29:nsq是go语言写的消息队列。请问k3s部署nsq,yaml如何写?

答案2022-12-29:

yaml如下:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nsq
  name: nsq
  namespace: moonfdd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nsq
  template:
    metadata:
      labels:
        app: nsq
    spec:
      containers:
        - image: "nsqio/nsq"
          imagePullPolicy: IfNotPresent
          name: nsqlookupd
          args:
            - "/nsqlookupd"
        - image: "nsqio/nsq"
          imagePullPolicy: IfNotPresent
          name: nsqd
          args:
            - "/nsqd"
            - "--lookupd-tcp-address"
            - "localhost:4160"
          volumeMounts:
            - mountPath: /data
              name: volv2
        - image: "nsqio/nsq"
          imagePullPolicy: IfNotPresent
          name: nsqadmin
          args:
            - "/nsqadmin"
            - "--lookupd-http-address"
            - "localhost:4161"
      volumes:
        - hostPath:
            path: /root/k8s/moonfdd/nsq/data
            type: DirectoryOrCreate
          name: volv2
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: nsq
  name: nsq
  namespace: moonfdd
spec:
  ports:
    - name: nsqlookupd0
      port: 4160
      protocol: TCP
      targetPort: 4160
    - name: nsqlookupd1
      port: 4161
      protocol: TCP
      targetPort: 4161
    - name: nsqd0
      port: 4150
      protocol: TCP
      targetPort: 4150
    - name: nsqd1
      port: 4151
      protocol: TCP
      targetPort: 4151
    - name: nsqadmin
      port: 4171
      protocol: TCP
      targetPort: 4171
  selector:
    app: nsq
  type: NodePort

从service得知web端口和curl命令的端口

web端口是58395
curl命令端口是36055
在这里插入图片描述

进入web页面,可以看到topics里啥都没有

在这里插入图片描述

敲curl命令,给nsq增加topic,名称是test

在这里插入图片描述

刷新web页面,可以看到topics里有test名称

在这里插入图片描述

posted @ 2022-12-29 20:41  福大大架构师每日一题  阅读(13)  评论(0编辑  收藏  举报  来源