Article Directory
introduce
Nacos /nɑ:kəʊs/ is the acronym for Dynamic Naming and Configuration Service, a dynamic service discovery, configuration management and service management platform that is easier to build cloud-native applications.
Nacos is dedicated to helping you discover, configure and manage microservices. Nacos provides a set of easy-to-use feature sets to help you quickly realize dynamic service discovery, service configuration, service metadata, and traffic management.
Nacos helps you build, deliver and manage microservice platforms more agilely and easily. Nacos is a service infrastructure for building a "service"-centric modern application architecture (such as microservice paradigm, cloud native paradigm).
preparation conditions
- Kubernetes 1.10+
- Helm v3
- PV provisioner support in the underlying infrastructure
- mysql
Create database, user name, import table structure
$ 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)
custom-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-server
tag: latest
pullPolicy: IfNotPresent
plugin:
enable: true
image:
repository: nacos/nacos-peer-finder-plugin
tag: 1.1
pullPolicy: IfNotPresent
replicaCount: 1
podManagementPolicy: Parallel
domainName: cluster.local
preferhostmode: hostname
serverPort: 8848
health:
enabled: false
storage:
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=false
persistence:
enabled: false
data:
accessModes:
- ReadWriteOnce
storageClassName: manual
resources:
requests:
storage: 5Gi
service:
#type: ClusterIP
type: NodePort
port: 8848
nodePort: 30000
ingress:
enabled: false
# apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1
annotations: {
}
# 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: nginx
ingressClassName: "nginx"
hosts:
- host: nacos.example.com
#paths: [ ]
tls: [ ]
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources:
# 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: 128Mi
requests:
cpu: 500m
memory: 2Gi
annotations: {
}
nodeSelector: {
}
tolerations: [ ]
affinity: {
}
deploy
helm install nacos ./
output:
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=1
cluster: kubectl scale sts default-nacos --replicas=3
examine
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/nacos-0 1/1 Running 0 8m36s
NAME 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 8m36s
NAME READY AGE
statefulset.apps/nacos 1/1 8m37s
log in
implement:
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
Access: https://192.168.23.14
:
user: nacos
password: nacos