查看“K8s应用”的源代码
←
K8s应用
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
=Monitoring= [https://www.kancloud.cn/huyipow/prometheus/527093 如何以优雅的姿势监控kubernetes 集群服务] =进阶= rancher =2022= [https://cloud.tencent.com/developer/article/2092943 K8S 部署电商项目] =2023 laravel= <pre> 放 mysql数据的 nfs data里面不能有文件 不然会报错 log 如下 2023-10-16 13:34:59+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.43-1.el7 started. 2023-10-16 13:35:04+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2023-10-16 13:35:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.43-1.el7 started. 2023-10-16 13:35:08+00:00 [Note] [Entrypoint]: Initializing database files 2023-10-16T13:35:08.154125Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2023-10-16T13:35:08.156183Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2023-10-16T13:35:08.156235Z 0 [ERROR] Aborting 1. pv apiVersion: v1 kind: PersistentVolume metadata: name: pv01 labels: pvname: pv01 spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Recycle nfs: path: /mydata/k8s server: 192.168.10.103 2. pvc apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql-persistentvolumeclaim spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi selector: #matchLabels: #pvname: pv0001 matchExpressions: - {key: pvname, operator: In, values: [pv01]} 3. mysql dp and service kind: Deployment apiVersion: apps/v1 metadata: name: mysql-deployment labels: app: mysql spec: selector: matchLabels: app: mysql strategy: type: Recreate template: metadata: labels: app: mysql spec: containers: - name: mysql image: mysql:5.7 env: - name: MYSQL_ALLOW_EMPTY_PASSWORD value: 'true' ports: - containerPort: 3306 volumeMounts: - mountPath: /var/lib/mysql name: mysql-storage volumes: - name: mysql-storage persistentVolumeClaim: claimName: mysql-persistentvolumeclaim --- kind: Service apiVersion: v1 metadata: name: mysql-service labels: app: mysql spec: selector: app: mysql ports: - port: 3306 targetPort: 3306 </pre> 每天5分钟的,以前应该有笔记的吧 https://www.cnblogs.com/CloudMan6/p/8323420.html [https://www.cnblogs.com/CloudMan6/p/8336904.html 用 Deployment 运行应用 - 每天5分钟玩转 Docker 容器技术(123)] =Kubernetes存储体系 PV PVC = [https://my.oschina.net/u/1787735/blog/4669428 详解Kubernetes存储体系] =kubernetes中服务的暴露访问方式= 2. Loadbalancer 使用NodeIp+Nodeport的方式实现,利用云平台提供的loadbalance服务,像aws、azure、openstack、gce都提供了loadbalance服务 这里不做介绍了 3. Ingress Ingress 使用开源的反向代理负载均衡器来实现对外暴漏服务,比如 Nginx、Apache、Haproxy等。Nginx Ingress 一般有三个组件组成: Nginx 反向代理负载均衡器 Ingress Controller 可以理解为控制器,它通过不断的跟 Kubernetes API 交互,实时获取后端 Service、Pod 等的变化,比如新增、删除等,然后结合 Ingress 定义的规则生成配置,然后动态更新上边的 Nginx 负载均衡器,并刷新使配置生效,来达到服务自动发现的作用。 Ingress 则是定义规则,通过它定义某个域名的请求过来之后转发到集群中指定的 Service。它可以通过 Yaml 文件定义,可以给一个或多个 Service 定义一个或多个 Ingress 规则。 --------------------- [https://blog.csdn.net/newcrane/article/details/79092577 kubernetes中服务的暴露访问方式kubernetes ingress使用] =国内应用例子= [https://my.oschina.net/u/3330830/blog/4917386 国内最具影响力科技创投媒体36Kr的容器化之路] = k8s 应用部署= [https://www.jenkins.io/doc/book/installing/kubernetes/ k8s jenkins] ==mediawiki k8s == [[Docker 安装mediawiki]] [https://jaas.ai/u/juju/mediawiki-k8s/3 mediawiki k8s] ==k8s wordpress == [https://www.qikqiak.com/k8s-book/docs/31.%E9%83%A8%E7%BD%B2%20Wordpress%20%E7%A4%BA%E4%BE%8B.html 部署 Wordpress 示例] [https://www.cnblogs.com/Dev0ps/p/10759116.html k8s经典实战—搭建WordPress] == K8S nginx volume之nfs挂载 没用pv pvc == <pre> #首先 nfs 88.122 mkdir /data/k8s/ng && chmod -R 0777/data/k8s/ng cat nfs_nginx.yaml --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx-nfs labels: web: nginx spec: replicas: 2 selector: matchLabels: appname: nginx template: metadata: labels: appname: nginx spec: containers: - name: nginx-nfs image: nginx volumeMounts: - name: nfs-test mountPath: /usr/share/nginx/html/ volumes: - name: nfs-test nfs: server: 192.168.88.122 path: /data/k8s/ng 查看结果 root@k8s-master:~# kubectl exec -it nginx-nfs-8465d697cc-584qd bash root@nginx-nfs-8465d697cc-584qd:/# cd /usr/share/nginx/html/ root@nginx-nfs-8465d697cc-584qd:/usr/share/nginx/html# ls root@nginx-nfs-8465d697cc-584qd:/usr/share/nginx/html# touch 1.html echo '36'>1.html 回来 nfs [root@work2 ~]# cat /data/k8s/ng/1.html 36 问题 coredns 问题 导致 curl IP 没成功 </pre> [https://blog.csdn.net/rookie23rook/article/details/109477398 Linux:K8S volume之nfs挂载] ==k8s mysql5.7 NFS 持久化== 问题 这个有时会断开 不过好像昨天 删除了好多pod pv pvc 后 今天搞了就不会了呢 Aug 31 2021 好的在 [[K8s mysql NFS 持久化]] [http://article.docway.net/details?id=606bf9430a6c642cafe25798 K8S 部署 Mysql(NFS 持久化)] [https://www.jianshu.com/p/1b001bf901c6 k8s使用nfs持久存储mysql数据的一次踩坑] <pre> 为什么mysql服务会不可用?为什么严重时整个k8s中的pod都处于pendding状态了呢? 写io是很耗cpu的,更何况这种大量复制。既然服务不可用了,我们使用top命令查看下k8s worker节点机器的各项性能,如下图。发现nfs在同步过程有一个nginx的command的进程cpu竟然达到了99%,us的cpu达到了23.5%,sy的cpu达到了48.6%,很显然,io同步时消耗了大量的cpu,导致mysql服务不可用了,而k8s的pod都会占用宿主机的cpu的资源的,如果宿主机的cpu资源不够pod所申明的cpu,pod将会重新构建,进而进入pod的生命周期中的pendding状态,所有pod都在争抢宿主机cpu的资源。 </pre> === NFS 搭建 === [[Debian(Ubuntu)安装nfs]] apt [[Nfs实现日志集中查看]] yum <pre> mkdir -p /data/k8s/mysql #on centos7 yum -y install nfs-utils root@work2 ~]# cat /etc/exports /data/k8s/ 192.168.88.0/24(sync,rw,no_root_squash) systemctl enable nfs systemctl restart nfs </pre> [https://www.jianshu.com/p/ceb14cf7cf80 k8s nfs的一个问题] ===创建命名空间=== kubectl create namespace db-mysql ===mysql-nfs-pv.yaml === <pre> #k8s master cat > /root/mysqltest/mysql-nfs-pv.yaml <<EOF kind: PersistentVolume apiVersion: v1 metadata: name: mysql-nfs-pv namespace: db-mysql spec: accessModes: - ReadWriteOnce capacity: storage: 2Gi persistentVolumeReclaimPolicy: Retain storageClassName: nfs nfs: path: /data/k8s/mysql server: 192.168.88.22 EOF kubectl apply -f mysql-nfs-pv.yaml </pre> === mysql-nfs-pvc.yaml=== <pre> cat > /root/mysqltest/mysql-nfs-pvc.yaml <<EOF kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mysql-nfs-pvc namespace: db-mysql spec: accessModes: - ReadWriteOnce resources: requests: storage: 2Gi storageClassName: nfs EOF kubecte apply -f mysql-nfs-pvc.yaml </pre> ===mysql-nfs-deploy.yaml === <pre> cat > /root/mysqltest/mysql-nfs-deploy.yaml <<EOF apiVersion: apps/v1 kind: Deployment metadata: name: mysql-nfs-deploy namespace: db-mysql spec: replicas: 1 selector: matchLabels: app: mysql_nfs template: metadata: labels: app: mysql_nfs spec: containers: - name: mysql57 image: mysql:5.7 imagePullPolicy: IfNotPresent env: - name: MYSQL_ROOT_PASSWORD value: "123456" args: - --lower_case_table_names=1 ports: - containerPort: 3306 volumeMounts: - name: mysql-persistent-storage mountPath: /var/lib/mysql volumes: - name: mysql-persistent-storage persistentVolumeClaim: claimName: mysql-nfs-pvc EOF kubectl apply -f mysql-nfs-deploy.yam </pre> === mysql-nfs-svc.yaml=== <pre> cat > /root/mysqltest/mysql-nfs-svc.yaml <<EOF apiVersion: v1 kind: Service metadata: name: mysql namespace: db-mysql spec: type: NodePort ports: - port: 3306 targetPort: 3306 nodePort: 32306 selector: app: mysql_nfs EOF </pre> ===查看相关 === <pre> kubectl get pods -A -o wide root@k8s-master:~/mysqltest# kubectl get pods -A -o wide | grep mysql-nfs default mysql-nfs-deploy-5f4fc57696-x49mw 1/1 Running 15 (5m27s ago) 84m 10.244.1.2 k8s-node1 <none> <none> root@k8s-master:~/mysqltest# </pre> ===查看mysql数据 on nfs master === <pre> 证明 这个nfs没问题呀 # ls /data/k8s/mysql/ auto.cnf ca.pem client-key.pem ib_logfile0 ibtmp1 performance_schema public_key.pem server-key.pem ca-key.pem client-cert.pem ibdata1 ib_logfile1 mysql private_key.pem server-cert.pem [root@work2 ~]# </pre> ===login mysql and other === <pre> kubectl exec -it mysql-nfs-deploy-5f4fc57696-x49mw /bin/bash 直接容器里面 没密码 哈哈 mysql -u root -p ysql> create database evan; 在nfs 服务器 ls /data/k8s/mysql/evan/ db.opt kubectl logs 遇上 mysql有bug kubectl logs mysql-nfs-deploy-5f4fc57696-x49mw We intentionally generate a memory trap 超级教程 k8s部署mysql数据持久化 https://www.cnblogs.com/pluto-charon/p/14411780.html </pre> [http://article.docway.net/details?id=606bf9430a6c642cafe25798 K8S 部署 Mysql(NFS 持久化)] [https://blog.csdn.net/shaochenshuo/article/details/107164676 innodb 表损坏,导致mysqld 重启] [https://www.cnblogs.com/Bccd/p/6868904.html MySQL5.7 服务 crash 后无法启动 ] ==see also== [https://www.jianshu.com/p/d1ab286e68d2 k8s+mysql+pv+pvc+NFS实现mysql容器编排] ==VPS== ===digitalocean=== 用他的服务 10/mo 如果是自己建呢 有CPU要求呢 还是买他的吧 两台 10/mon 但是自由,试一下这个行不行先, 等于还多了两个vm,不过上次的helm 2还是不成功呢 [https://juejin.im/post/5caa00346fb9a05e677e8c52 在DigitalOcean玩Kubernetes(K8S)] https://www.digitalocean.com/docs/kubernetes/overview/ ===vultr=== 这个看起来贵一点 这个vps下次暂停一下 不要浪费一个月5刀呢 ==[[K8s on aliyun]]== ==othre== [https://www.centos.bz/2018/10/kubernetes%E4%BD%BF%E7%94%A8%E8%BF%87%E7%A8%8B%E4%B8%AD%E9%81%87%E5%88%B0%E7%9A%84%E4%B8%80%E4%BA%9B%E9%97%AE%E9%A2%98%E4%B8%8E%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/ Kubernetes使用过程中遇到的一些问题与解决方法] [https://www.jianshu.com/p/65c4baadf5d9 从零开始搭建Kubernetes集群(六、在K8S上部署Redis 集群)] [https://www.jianshu.com/p/feeea0bbd73e 从零开始搭建Kubernetes集群(五、搭建K8S Ingress] [https://www.jianshu.com/p/6f42ac331d8a 从零开始搭建Kubernetes集群(四、搭建K8S Dashboard)] [https://www.jianshu.com/p/b264b6cf9340 从零开始搭建Kubernetes集群(七、如何监控K8S集群日志)] [https://blog.51cto.com/superleedo/2050208 在kubernetes中部署tomcat与mysql集群] [https://yq.aliyun.com/articles/448676 全面提升,阿里云Docker/Kubernetes(K8S) 日志解决方案与选型对比] [https://my.oschina.net/u/3994209/blog/2998856 部署你的第一个ASP.NET Core应用到k8s集群] [https://www.jianshu.com/p/65c4baadf5d9 从零开始搭建Kubernetes集群(六、在K8S上部署Redis 集群)] [https://www.centos.bz/2017/07/kubernetes-deploy-test-nginx-service/ Kubernetes(k8s)部署并测试nginx service] [https://www.centos.bz/2018/10/%E4%B8%AA%E6%8E%A8%E5%9F%BA%E4%BA%8E-docker-%E5%92%8C-kubernetes-%E7%9A%84%E5%BE%AE%E6%9C%8D%E5%8A%A1%E5%AE%9E%E8%B7%B5/ 个推基于 Docker 和 Kubernetes 的微服务实践] [https://linuxtoy.org/archives/nextcontainer.html 《拥抱下一代容器化工具》视频及电子书发布] [https://github.com/helm/charts/tree/master/incubator/gogs helm gogs] [https://blog.csdn.net/AtlanSI/article/details/80849927 K8S集群搭建,并部署nginx实现跨网络访问] ===java tomcat === [https://blog.csdn.net/u013201439/article/details/79306417 Kubernetes】部署Tomcat服务] [https://blog.csdn.net/ljx1528/article/details/85259401 k8s部署tomcat数据持久化] [https://blog.csdn.net/MassiveStars/article/details/54352484 Docker实践 - 安装Docker并在容器里运行tomcat] ==trouble== [http://itindex.net/detail/57343-kube-proxy-%E5%A4%96%E9%83%A8 使用kube-proxy让外部网络访问K8S service的ClusterIP] [https://www.cnblogs.com/puroc/p/6337045.html telnet master主机的NodePort服务不通的问题] [https://blog.csdn.net/weixin_38380858/article/details/88830853 kubernetes踩坑:nodePort拒绝访问的问题] [https://www.jianshu.com/p/ce1028c1cbc0 通过NodePort向k8s集群外部暴露服务] [https://www.cnblogs.com/aguncn/p/7202676.html K8s的内部Pod之间都不通,搞了快两天] [https://www.cnblogs.com/lykops/p/7348020.html 使用kube-proxy让外部网络访问K8S service的ClusterIP] [https://blog.csdn.net/zhonglinzhang/article/details/86074298 【kubernetes/k8s概念】kube-proxy启动参数] [[category:k8s]]
返回至
K8s应用
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
我的导航
关于我
shell
python
ops
linuxchina.net
blog.linuxchina
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息