我正在尝试在基于ubuntu服务器19最新补丁的前提下将SQLServer Always On始终部署到kubernetes集群中
这里是设置
Kubeadm v1.16.0
Docker 18.09.7
Nodes
NAME STATUS ROLES AGE VERSION
master-node Ready master 6d19h v1.16.0
slave-node1 Ready <none> 6d18h v1.16.0
slave-node2 Ready <none> 6d19h v1.16.0
[版本表] [1]
我无法部署sqlserver容器,但没有收到错误,但没有部署容器,当我检查我的pvc时,它没有被绑定,但它说在绑定之前要等待第一个使用者创建。
kubectl describe pvc mssql-data1-claim -n ag1
Name: mssql-data1-claim
Namespace: ag1
StorageClass: local-storage
Status: Pending
Volume:
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"mssql-data1-claim","namespace":"ag1"},"spec":{"acce...
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Mounted By: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal WaitForFirstConsumer 109s (x42 over 12m) persistentvolume-controller waiting for first consumer to be created before binding
您能指出我对Kubernetes的新错误和当前正在学习的内容吗? 感谢所有帮助
这是我使用的YAML定义
存储类
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
PV和PV索赔
kind: PersistentVolume
apiVersion: v1
metadata:
name: ag1-pv-volume-node1
labels:
type: local
spec:
storageClassName: default
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
local:
path: "/var/opt/mssql"
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- slave-node1
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data1-claim
namespace: ag1
spec:
storageClassName: default
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
selector:
matchLabels:
name: ag1-pv-volume-node1
操作员文件
SqlServer部署
apiVersion: mssql.microsoft.com/v1
kind: SqlServer
metadata:
labels: {name: mssql1, type: sqlservr}
name: mssql1
namespace: ag1
spec:
acceptEula: true
agentsContainerImage: mcr.microsoft.com/mssql/ha:2019-CTP2.1-ubuntu
availabilityGroups: [ag1]
instanceRootVolumeClaimTemplate:
accessModes: [ReadWriteOnce]
resources:
requests: {storage: 3Gi}
storageClass: default
saPassword:
secretKeyRef: {key: sapassword, name: sql-secrets}
sqlServerContainer: {image: 'mcr.microsoft.com/mssql/server:2019-CTP2.1-ubuntu'}
volumes:
- name: sql-server-storage1
persistentVolumeClaim:
claimName: mssql-data1-claim
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- slave-node1
---
apiVersion: v1
kind: Service
metadata: {name: mssql1, namespace: ag1}
spec:
ports:
- {name: tds, port: 1433}
selector: {name: mssql1, type: sqlservr}
type: NodePort
这是kubectl get pods -A的结果
NAMESPACE NAME READY STATUS RESTARTS AGE
ag1 mssql-operator-5c85589dfb-j2t6f 1/1 Running 0 3d23h
kube-system coredns-5644d7b6d9-dh9fg 1/1 Running 2 6d20h
kube-system coredns-5644d7b6d9-p84nl 1/1 Running 2 6d20h
kube-system etcd-master-node 1/1 Running 2 6d19h
kube-system kube-apiserver-master-node 1/1 Running 3 6d19h
kube-system kube-controller-manager-master-node 1/1 Running 5 6d19h
kube-system kube-flannel-ds-amd64-cpsf9 1/1 Running 1 6d19h
kube-system kube-flannel-ds-amd64-d5sj4 1/1 Running 2 6d18h
kube-system kube-flannel-ds-amd64-jg6pd 1/1 Running 2 6d19h
kube-system kube-proxy-2cq5m 1/1 Running 2 6d20h
kube-system kube-proxy-8rc4m 1/1 Running 1 6d19h
kube-system kube-proxy-rh27f 1/1 Running 1 6d18h
kube-system kube-scheduler-master-node 1/1 Running 4 6d19h
kubernetes-dashboard dashboard-metrics-scraper-566cddb686-dmns8 1/1 Running 1 6d18h
kubernetes-dashboard kubernetes-dashboard-7b5bf5d559-6nqsm 1/1 Running 7 6d18h
答案 0 :(得分:0)
欢迎使用StackOverflow @Ricardo,
根据我自己的经验,您需要首先进行一些整理,以使HA MSSQL Server在Linux worker上与“ mssql-operator”一起使用,而无需在“ deploy-ag.py
”脚本中进行重大更改
我假设您正在./deploy-ag.py deploy
模式下运行'--dry-run
',以便您有机会在使用kubectl
应用某些清单之前对其进行调整。
确保“ PVC”可以绑定到先前创建的“本地”类型的“ PV”
PV_1.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
labels: {storage: ag1}
name: ag1-mssql1-pv
spec:
accessModes: [ReadWriteOnce]
capacity: {storage: 2Gi}
local:
path: "/mnt/data"
storageClassName: gp2
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node-1.region.compute.internal
github上的代码示例包含sqlServerContainer映像的过时版本,这将导致以下错误msg。在sqlservr
进程启动时:
错误:评估期已过。该程序遇到了 致命错误,无法继续运行。
在“ Kubernetes / sample-deployment-script / templates / sqlserver.yaml ”模板中调整以下内容:
<!Before>
sqlServerContainer:
image: mcr.microsoft.com/mssql/server:2019-CTP2.1-ubuntu
<!After>
sqlServerContainer:
image: mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu
此时,您应该可以与HA-SQL Server实例进行对话
使用命令进行快速验证的过程:
kubectl exec po/mssql1-0 -c mssql-server -n ag1 -- /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <your password> -Q "SELECT name FROM sys.databases
预期输出:
名称
--------主tempdb
型号
msdb(受影响的4行)