拉取開源代碼git
mkdir ~/dev/apache cd ~/dev/apache git clone https://github.com/apache/pulsar.git cd pulsar #從TAG v2.6.1 建立本地分支 git checkout -b v2.6.1_build v2.6.1
編譯Jar包,並打包成發佈包github
mvn install -DskipTests # 查看編譯後的結果 cd distribution/ tree ./ cd server/target tree ./
解壓上面編譯打包好的發佈包,並啓動單機模式,可用於本地開發測試docker
cd ~/dev/apache/pulsar/distribution/server/target # 解壓編譯好的Jar包 tar -zxvf apache-pulsar-2.6.1-bin.tar.gz cd apache-pulsar-2.6.1 # 修改單機模式的配置文件 vim conf/standalone.conf # 啓動單機模式Pulsar bin/pulsar standalone # 關閉單機模式Pulsar Ctrl + c
單機模式開啓 JWT認證 配置示例apache
# 生成secret和tokens mkdir -p /tmp/test-jwt bin/pulsar tokens create-secret-key --output /tmp/test-jwt/my-base64-secret.key --base64 bin/pulsar tokens create --secret-key file:///tmp/test-jwt/my-base64-secret.key --subject my-jwt-user > /tmp/test-jwt/my-jwt-user.tokens # 修改認證相關的配置項 vim conf/standalone.conf authenticationEnabled=true authenticationProviders=org.apache.pulsar.broker.authentication.AuthenticationProviderToken tokenSecretKey=file:///tmp/test-jwt/my-base64-secret.key brokerClientAuthenticationPlugin=org.apache.pulsar.client.impl.auth.AuthenticationToken brokerClientAuthenticationParameters=file:///tmp/test-jwt/my-jwt-user.tokens # 啓動單機模式Pulsar bin/pulsar standalone
將上述編譯打包好的發佈包構建成Docker鏡像vim
# 構建鏡像 cd ~/dev/apache/pulsar/docker ./build.sh # 查看構建的鏡像 docker images | grep pulsar
推送鏡像到鏡像倉庫ssh
docker tag apachepulsar/pulsar-all:2.6.1 registry.example.tabalt.net/pulsar-test/pulsar-all:2.6.1 docker login --username=xxx --password=yyy registry.example.tabalt.net docker push registry.example.tabalt.net/pulsar-test/pulsar-all:2.6.0
# 登錄K8s master機器 ssh k8s-master.example.tabalt.net # 安裝本地存儲卷 kubectl create namespace local-storage helm repo add streamnative https://charts.streamnative.io helm repo update helm install local-storage-provisioner streamnative/local-storage-provisioner \ --set namespace=local-storage -n local-storage kubectl get pods -n local-storage -o wide # 拉取pulsar helm chart mkdir pulsar cd pulsar/ git clone https://github.com/apache/pulsar-helm-chart.git cd pulsar-helm-chart git checkout -b v2.6.1_deploy pulsar-2.6.1 # 部署Pular ./scripts/pulsar/prepare_helm_release.sh -c -n pulsar -k pulsar helm upgrade --install pulsar charts/pulsar \ --set images.zookeeper.repository=registry.example.tabalt.net/pulsar-test/pulsar-all \ --set images.bookie.repository=registry.example.tabalt.net/pulsar-test/pulsar-all \ --set images.autorecovery.repository=registry.example.tabalt.net/pulsar-test/pulsar-all \ --set images.broker.repository=registry.example.tabalt.net/pulsar-test/pulsar-all \ --set images.proxy.repository=registry.example.tabalt.net/pulsar-test/pulsar-all \ --set images.functions.repository=registry.example.tabalt.net/pulsar-test/pulsar-all \ --set bookkeeper.metadata.image.repository=registry.example.tabalt.net/pulsar-test/pulsar-all \ --set pulsar_metadata.image.repository=registry.example.tabalt.net/pulsar-test/pulsar-all \ --set namespace=pulsar --set volumes.local_storage=true \ -n pulsar kubectl get pods -n pulsar -o wide # 查看是pod鏡像版本是否匹配 kubectl describe pod pulsar-bookie-0 -n pulsar | grep image # 刪除原來的Pulsar(若有),請注意不要誤刪線上集羣並確保他人未在使用 helm uninstall pulsar -n pulsar kubectl delete namespace pulsar