1. k8s 对接glusterfs存储

a:创建endpoint

#查看
kubectl describe svc myweb
kubectl get endpoints myweb
kubectl describe endpoints myweb

#创建
[root@k8s-master ~]# cd k8s\_yaml/
[root@k8s-master k8s_yaml]# mkdir gfs
[root@k8s-master k8s_yaml]# cd gfs/

#添加文件
[root@k8s-master gfs]# vim glusterfs-ep.yaml 
apiVersion: v1
kind: Endpoints
metadata:
  name: glusterfs
  namespace: default
subsets:
- addresses:
  - ip: 10.0.0.11
  - ip: 10.0.0.12
  - ip: 10.0.0.13
  ports:
  - port: 49152
    protocol: TCP

#创建并查看
[root@k8s-master gfs]# kubectl create -f glusterfs-ep.yaml 
endpoints "glusterfs" created
[root@k8s-master gfs]# kubectl get endpoints 
NAME               ENDPOINTS                                         AGE
glusterfs          10.0.0.11:49152,10.0.0.12:49152,10.0.0.13:49152   9s
kubernetes         10.0.0.11:6443                                    6d
mysql              <none>                                            1d
myweb              172.18.13.7:8080                                  1d
nginx              172.18.13.7:80                                    5d
nginx-deployment   172.18.13.5:80                                    1d


b:glusterfs-svc.yaml

[root@k8s-master gfs]# vim glusterfs-svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: glusterfs
  namespace: default
spec:
  ports:
  - port: 49152
    protocol: TCP
    targetPort: 49152
  sessionAffinity: None
  type: ClusterIP
[root@k8s-master gfs]# kubectl create -f glusterfs-svc.yaml 
service "glusterfs" created

c: 创建gluster类型pv

#配置文件中的glusterfs名是用昨天创建好的wahaha

[root@k8s-master gfs]# vim glusterfs-pv.yaml 
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gluster
  labels:
    type: glusterfs
spec:
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteMany
  glusterfs:
    endpoints: "glusterfs"
    path: "wahaha"
    readOnly: false

[root@k8s-master gfs]# kubectl create -f glusterfs-pv.yaml 
persistentvolume "gluster" created
[root@k8s-master gfs]# kubectl get pv
NAME      CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS      CLAIM     REASON    AGE
gluster   20Gi       RWX           Retain          Available                       5s


d:k8s_pvc.yaml

[root@k8s-master gfs]# vim k8s\_pvc.yaml 
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: tomcat-mysql
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 20Gi


[root@k8s-master gfs]# kubectl create -f k8s\_pvc.yaml 
persistentvolumeclaim "tomcat-mysql" created
[root@k8s-master gfs]# kubectl get pvc
NAME           STATUS    VOLUME    CAPACITY   ACCESSMODES   AGE
tomcat-mysql   Bound     gluster   20Gi       RWX           9s
[root@k8s-master gfs]# kubectl get pvc -n default
NAME           STATUS    VOLUME    CAPACITY   ACCESSMODES   AGE
tomcat-mysql   Bound     gluster   20Gi       RWX           19s


e:mysql-rc-pvc.yaml

[root@k8s-master tomcat_demo]# cp mysql-rc-nfs.yaml mysql-rc-pvc.yaml
[root@k8s-master tomcat_demo]# cat mysql-rc-pvc.yaml 
apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      volumes: 
      - name: mysql 
        persistentVolumeClaim:
          claimName: tomcat-mysql 
      containers:
        - name: mysql
          volumeMounts:
          - mountPath: /var/lib/mysql
            name: mysql
          image: 10.0.0.11:5000/mysql:5.7
          ports:
          - containerPort: 3306
          env:
          - name: MYSQL_ROOT_PASSWORD
            value: '123456'

[root@k8s-master tomcat_demo]# kubectl delete -f mysql-rc-pvc.yaml 
replicationcontroller "mysql" deleted
[root@k8s-master tomcat_demo]# kubectl create -f mysql-rc-pvc.yaml 
replicationcontroller "mysql" created
[root@k8s-master tomcat_demo]# kubectl get pod -o wide
NAME                                READY     STATUS    RESTARTS   AGE       IP            NODE
mysql-p2xkq                         1/1       Running   0          10m       172.18.81.4   k8s-node1
myweb-41l9f                         1/1       Running   1          16h       172.18.13.7   k8s-node2

f:浏览器访问添加数据后再删除pod

#创建新数据后删除mysql的pod会自动生成新的pod
kubectl delete pod mysql-m3zm9

浏览器再次访问数据还在

g:在node2节点上查看/mnt目录

[root@k8s-node2 ~]# mount -t glusterfs 10.0.0.11:/wahaha /mnt
[root@k8s-node2 mnt]# df -h
10.0.0.11:/wahaha   30G  615M   30G   3% /mnt

[root@k8s-node2 mnt]# ll
total 188434
-rw-r----- 1 polkitd input       56 Sep 18 09:45 auto.cnf
drwxr-x--- 2 polkitd input     4096 Sep 18 09:47 HPE_APP
-rw-r----- 1 polkitd input      719 Sep 18 09:47 ib_buffer_pool
-rw-r----- 1 polkitd input 79691776 Sep 18 09:47 ibdata1
-rw-r----- 1 polkitd input 50331648 Sep 18 09:47 ib_logfile0
-rw-r----- 1 polkitd input 50331648 Sep 18 09:45 ib_logfile1
-rw-r----- 1 polkitd input 12582912 Sep 18 09:47 ibtmp1
drwxr-x--- 2 polkitd input     4096 Sep 18 09:45 mysql
drwxr-x--- 2 polkitd input     4096 Sep 18 09:45 performance_schema
drwxr-x--- 2 polkitd input     4096 Sep 18 09:45 sys

2. 与jenkins集成实现ci/cd

jenkins 工具 自动化代码上线
核心功能 支持大量的插件

jenkins java代码

比如之前做的小鸟飞飞是纯html页面
如果想换个小鸟的颜色怎么做呢
html文件 站点
开发写好代码传给运维 然后运维进行上传解压

代码版本管理软件

git: github

git check out

git tag

shell脚本

java类型
java项目代码上线链接

java

需要编译
.cless

2.1 安装gitlab并上传代码


需要的软件下载链接 提取码: dshc

#上传代码包
[root@k8s-node2 jenkins-k8s]# ll
total 890176
-rw-r--r-- 1 root root   9128610 Sep 18 10:48 apache-tomcat-8.0.27.tar.gz
-rw-r--r-- 1 root root 569408968 Sep 18 10:49 gitlab-ce-11.9.11-ce.0.el7.x86_64.rpm
-rw-r--r-- 1 root root 166044032 Sep 18 10:48 jdk-8u102-linux-x64.rpm
-rw-r--r-- 1 root root  89566714 Sep 18 10:49 jenkin-data.tar.gz
-rw-r--r-- 1 root root  77289987 Sep 18 10:49 jenkins.war
-rw-r--r-- 1 root root     91014 Sep 18 10:49 xiaoniaofeifei.zip

#安装
[root@k8s-node2 jenkins-k8s]# rpm -ivh gitlab-ce-11.9.11-ce.0.el7.x86\_64.rpm

#配置
vim /etc/gitlab/gitlab.rb
external_url 'http://10.0.0.13'
prometheus_monitoring['enable'] = false

#应用并启动服务
gitlab-ctl reconfigure

#使用浏览器访问http://10.0.0.13,修改root用户密码,创建project



gitlab 11.1.4(不限版本)汉化方法

创建项目

[root@k8s-node2 opt]# cd /srv/
[root@k8s-node2 srv]# ls
[root@k8s-node2 srv]# git clone https://gitlab.com/xhang/gitlab.git
Cloning into 'gitlab'...

#确保有git命令
[root@k8s-node2 srv]# which git
/usr/bin/git
[root@k8s-node2 srv]# git config --global user.name "Administrator"
[root@k8s-node2 srv]# git config --global user.email "admin@example.com"
[root@k8s-node2 srv]# cat /root/.gitconfig 
[user]
	name = Administrator
	email = admin@example.com
	
[root@k8s-node2 srv]# mv /root/jenkins-k8s/xiaoniaofeifei.zip .
[root@k8s-node2 srv]# unzip xiaoniaofeifei.zip 
[root@k8s-node2 srv]# ls
2000.png  21.js  icon.png  img  index.html  sound1.mp3  xiaoniaofeifei.zip


上传代码

git init
git remote add origin http://10.0.0.13/root/xiaoniao.git
git add .
git commit -m "Initial commit"

#登录账户密码
[root@k8s-node2 srv]# git push -u origin master
Username for 'http://10.0.0.13': root
Password for 'http://root@10.0.0.13': 


上传成功

2.2 安装jenkins,并自动构建docker镜像

node1上安装jenkins

[root@k8s-node1 opt]# ll
total 334020
-rw-r--r-- 1 root root   9128610 Sep 18 11:53 apache-tomcat-8.0.27.tar.gz
-rw-r--r-- 1 root root 166044032 Sep 18 11:54 jdk-8u102-linux-x64.rpm
-rw-r--r-- 1 root root  89566714 Sep 18 11:54 jenkin-data.tar.gz
-rw-r--r-- 1 root root  77289987 Sep 18 11:54 jenkins.war

rpm -ivh jdk-8u102-linux-x64.rpm 
mkdir /app
tar xf apache-tomcat-8.0.27.tar.gz -C /app
rm -fr /app/apache-tomcat-8.0.27/webapps/*
mv jenkins.war /app/apache-tomcat-8.0.27/webapps/ROOT.war
tar xf jenkin-data.tar.gz -C /root
/app/apache-tomcat-8.0.27/bin/startup.sh 
netstat -lntup

2.3 浏览器访问jenkins

访问http://10.0.0.12:8080/,默认账号密码admin:123456

2.4 配置jenkins拉取gitlab代码凭据

a:在jenkins上生成秘钥对

#生成秘钥 一路回车
[root@k8s-node1 opt]# ssh-keygen -t rsa

[root@k8s-node1 opt]# ls /root/.ssh/
id_rsa  id_rsa.pub  known_hosts


b:复制公钥粘贴gitlab上

新建秘钥的进入方法

c:在node1上查看秘钥

[root@k8s-node1 opt]# cat /root/.ssh/id\_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrlIgDVptvmipg00CP7P955Nbn2h+oy06hUiYWE+htG6VjLSCFjEhrxgXOCX2EAKGLgveWA46MLt4XN2Gi4E1H3aDsM/gBu8D+4487bKuLKv1ZeMeWECcDKL16cjtSQw6ShsCLBwh3aq5TT85I/ypUYMsQ1+N4Iiv4i3g3ozn0yPsyMq9rekW+nHbs8eJL1OzIue6hL78AgI8QuZ7QaCQ5TJDmCwKuLC+B+6ajyNezSxBIlZeBuUE5lacKmvxxnX5Dqzlvf5uGrVRSgPCR6oTTDTHmx2GVHIl7BJLZH/uR4tP7gYoY9fFOM1VyJ8Pjq+XcLGYFWNQKTgxKQO/08sjr root@k8s-node1


d:jenkins上创建全局凭据

[root@k8s-node1 opt]# cat /root/.ssh/id\_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAq5SIA1abb5oqYNNAj+z/eeTW59ofqMtOoVImFhPobRulYy0g
hYxIa8YFzgl9hAChi4L3lgOOjC7eFzdhouBNR92g7DP4AbvA/uOPO2yriyr9WXjH
lhAnAyi9enI7UkMOkobAiwcId2quU0/OSP8qVGDLENfjeCIr+It4N6M59Mj7MjKv
a3pFvpx27PHiS9TsyLnuoS+/AICPELme0GgkOUyQ5gsCriwvgfumo8jXs0sQSJWX
gblBOZWnCpr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ywu9QoosVqOTV2yCuZMHearcHSTMI6YU
fjdjap/bPM7INse6b20wCFxVEomfzoLY0X3NhS1MKMdexzTBFngdJHrmXGYS7M9Z
fr4V0EECgYAb1ZXLghOZDFp80DLryQPaFz63kIf5HKGQM5KJBos7bq5vmxnuyT3f
5BTLNSdmpAdjXmHXvzynEWeg/bkDRXK4iFMvGQj0fo1MNbodyj6BcUSH6M7C1Srm
MVroh40pZQbAdeCOlJmDSdxhiRc0rVlmtTuIzS80yHW91Cfn4nk3ag==
-----END RSA PRIVATE KEY-----

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数大数据工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上大数据开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注大数据获取)
img

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

.(img-2eDo7Rbl-1713105649499)]
[外链图片转存中…(img-pINclNOK-1713105649499)]
[外链图片转存中…(img-F7eWqdzV-1713105649500)]
[外链图片转存中…(img-5BrGpa1u-1713105649500)]
[外链图片转存中…(img-G42zUAWN-1713105649500)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上大数据开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注大数据获取)
[外链图片转存中…(img-0Qxyoc99-1713105649500)]

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐