文章目录
- 介绍
- 准备条件
- 定制 values.yaml
- 检查
- 登陆
介绍
Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service的首字母简称,一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。
Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。
Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。 Nacos 是构建以“服务”为中心的现代应用架构 (例如微服务范式、云原生范式) 的服务基础设施。
准备条件
- Kubernetes 1.10+
- Helm v3
- PV provisioner support in the underlying infrastructure
- 部署 openebs-lvmlocalpv
- Kubernetes 使用 helm 部署 NFS Provisioner
- mysql
- kubernetes deploy standalone mysql demo
创建数据库、用户名、导入表结构
$ mysql -h 192.168.23.21 -u root -P 30006 -p'password'
mysql> create database nacos_config character set utf8;
mysql> create user 'nacos'@'%' identified by 'nacos';
mysql> grant all privileges ON nacos_config.* TO 'nacos'@'%';
mysql>use nacos_config; $ wget https://raw.githubusercontent.com/alibaba/nacos/develop/distribution/conf/mysql-schema.sql
$ mysql -h 192.168.23.21 -u root -P 30006 -p'password' -D nacos_config < mysql-schema.sql
$ mysql -h 192.168.23.21 -u root -P 30006 -p'password' -D nacos_config
mysql> show tables;
+------------------------+
| Tables_in_nacos_config |
+------------------------+
| config_info |
| config_info_aggr |
| config_info_beta |
| config_info_tag |
| config_tags_relation |
| group_capacity |
| his_config_info |
| permissions |
| roles |
| tenant_capacity |
| tenant_info |
| users |
+------------------------+
12 rows in set (0.00 sec)
定制 values.yaml
git clone https://github.com/nacos-group/nacos-k8s.git
cd nacos-k8s/helm
vim values.yaml
# Default values for nacos.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.global:mode: standalone
# mode: cluster############################nacos###########################
namespace: default
nacos:image:repository: nacos/nacos-servertag: latestpullPolicy: IfNotPresentplugin:enable: trueimage:repository: nacos/nacos-peer-finder-plugintag: 1.1pullPolicy: IfNotPresentreplicaCount: 1podManagementPolicy: ParalleldomainName: cluster.localpreferhostmode: hostnameserverPort: 8848health:enabled: falsestorage:type: embedded
# type: mysql
# db:
# host: localhost
# name: nacos
# port: 3306
# username: usernmae
# password: password
# param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=falsepersistence:enabled: falsedata:accessModes:- ReadWriteOncestorageClassName: manualresources:requests:storage: 5Giservice:#type: ClusterIPtype: NodePortport: 8848nodePort: 30000ingress:enabled: false# apiVersion: extensions/v1beta1apiVersion: networking.k8s.io/v1annotations: { }# kubernetes.io/ingress.class: nginx# kubernetes.io/tls-acme: "true"# For Kubernetes >= 1.18 you should specify the ingress-controller via the field ingressClassName# See https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/#specifying-the-class-of-an-ingress# ingressClassName: nginxingressClassName: "nginx"hosts:- host: nacos.example.com#paths: [ ]tls: [ ]# - secretName: chart-example-tls# hosts:# - chart-example.localresources:# We usually recommend not to specify default resources and to leave this as a conscious# choice for the user. This also increases chances charts run on environments with little# resources, such as Minikube. If you do want to specify resources, uncomment the following# lines, adjust them as necessary, and remove the curly braces after 'resources:'.# limits:# cpu: 100m# memory: 128Mirequests:cpu: 500mmemory: 2Gi
annotations: { }nodeSelector: { }tolerations: [ ]affinity: { }
部署
helm install nacos ./
输出:
NAME: nacos
LAST DEPLOYED: Mon Sep 4 20:10:59 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services nacos-cs)export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")echo http://$NODE_IP:$NODE_PORT/nacos
2. MODE:standalone: you need to modify replicaCount in the values.yaml, .Values.replicaCount=1cluster: kubectl scale sts default-nacos --replicas=3
检查
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/nacos-0 1/1 Running 0 8m36sNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 48d
service/nacos-cs NodePort 10.99.163.228 <none> 8848:32575/TCP,9848:30113/TCP,9849:30338/TCP,7848:30000/TCP 8m36sNAME READY AGE
statefulset.apps/nacos 1/1 8m37s
登陆
执行:
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services nacos-cs)export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")echo http://$NODE_IP:$NODE_PORT/nacos
访问:https://192.168.23.14
:
用户:nacos
密码:nacos