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

Posted 福大大架构师每日一题

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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名称

以上是关于2022-12-29:nsq是go语言写的消息队列。请问k3s部署nsq,yaml如何写?的主要内容,如果未能解决你的问题,请参考以下文章

带你入门Go语言的消息队列NSQ

Go消息中间件Nsq系列(七)------go-diskqueue 文件队列实现

12.1 Go nsq

NSQ

NSQ

消息队列 NSQ 源码学习笔记