This 2-Node Kubernetes cluster is broken! Troubleshoot, fix the cluster issues and then deploy the objects according to the given architecture diagram to unlock our Image Gallery!!
1、
- kubeconfig = /root/.kube/config, User = ‘kubernetes-admin’ Cluster: Server Port = ‘6443’'.
- Fix kube-apiserver. Make sure its running and healthy.
- Master node: coredns deployment has image: ‘registry.k8s.io/coredns/coredns:v1.8.6’
首先查看错误提示:
显示端口连接被拒绝,查看端口是否正常
由此可见端口错误,修改端口为6443
vim .kube/config
server:https://controlplane:6443
其次,查看apiserver日志,看错误在哪里
根据日志提示,修改kube-apiserver.yml文件里的证书名称,之后重启kubelet即可
最后,查看coredns pod的状态
修改镜像地址
确认running
2、
Copy all images from the directory ‘/media’ on the controlplane node to ‘/web’ directory on node01
scp /media/* node01:/web/
3、
- Create new PersistentVolume = ‘data-pv’
- PersistentVolume = data-pv, accessModes = ‘ReadWriteMany’
- PersistentVolume = data-pv, hostPath = ‘/web’
- PersistentVolume = data-pv, storage = ‘1Gi’
apiVersion: v1
kind: PersistentVolume
metadata:name: data-pvlabels:type: local
spec:storageClassName: manualcapacity:storage: 1GiaccessModes:- ReadWriteManyhostPath:path: "/web"
4、
- Create new PersistentVolumeClaim = ‘data-pvc’
- PersistentVolume = ‘data-pvc’, accessModes = ‘ReadWriteMany’
- PersistentVolume = ‘data-pvc’, storage request = ‘1Gi’
- PersistentVolume = ‘data-pvc’, volumeName = ‘data-pv’
apiVersion: v1
kind: PersistentVolumeClaim
metadata:name: data-pvc
spec:accessModes:- ReadWriteManyresources:requests:storage: 1GivolumeName: data-pv
5、
- New Service, name: ‘gop-fs-service’
- Service name: gop-fs-service, port: ‘8080’
- Service name: gop-fs-service, targetPort: ‘8080’
- Service name: gop-fs-service, NodePort: ‘31200’
apiVersion: v1
kind: Service
metadata:name: gop-fs-service
spec:type: NodePortselector:app.kubernetes.io/name: gop-fs-serverports:- protocol: TCPport: 8080targetPort: 8080nodePort: 31200
6、
Create a pod for file server, name: ‘gop-file-server’
pod: gop-file-server image: ‘kodekloud/fileserver’
pod: gop-file-server mountPath: ‘/web’
pod: gop-file-server volumeMount name: ‘data-store’
pod: gop-file-server persistent volume name: data-store
pod: gop-file-server persistent volume claim used: ‘data-pvc’
apiVersion: v1
kind: Pod
metadata:name: gop-file-server
spec:volumes:- name: data-storepersistentVolumeClaim:claimName: data-pvccontainers:- name: gop-file-serverimage: kodekloud/fileservervolumeMounts:- mountPath: "/web"name: data-store