51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

游戏镜像上K8S

参考案例
	1.下载镜像
[root@master231 classroomExercises]# wget http://192.168.11.253/Kubernetes/day03-/images/games_v0.4.tar.gz
[root@master231 classroomExercises]# docker load -i games_v0.4.tar.gz 
[root@master231 classroomExercises]# docker tag baimei2020/baimei-games:v0.4 harbor.baimei.com/baimei-games/games:v0.4
[root@master231 classroomExercises]# docker push harbor.baimei.com/baimei-games/games:v0.4


	2.编写资源清单
[root@master231 classroomExercises]# cat pods-games.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: baimei-games-002
spec:
  nodeName: worker233
  # hostNetwork: true
  containers:
  - name: games
    image: harbor.baimei.com/baimei-games/games:v0.4
    # args:
    # - tail
    # - -f 
    # - /etc/hosts
    ports:
    - containerPort: 80
      hostPort: 80
[root@master231 classroomExercises]# 
 

	3.拷贝代码目录
[root@master231 classroomExercises]# kubectl cp killbird baimei-games:/usr/local/nginx/html
	
	
	4.修改nginx的配置文件
[root@master231 classroomExercises]# kubectl exec -it baimei-games sh
/usr/local/nginx/html/killbird # 
/usr/local/nginx/html/killbird # 
/usr/local/nginx/html/killbird # vi /etc/nginx/conf.d/games.conf 
...
server {
    listen        0.0.0.0:80;
    root          /usr/local/nginx/html/killbird/;
    server_name   game18.baimei.com;
}

/usr/local/nginx/html/killbird # nginx 


	5.wind访问测试
http://game18.baimei.com/



提交镜像案例:
	1..进入容器进行打包
[root@master231 tmp]# kubectl exec -ti baimei-games-002 -- sh
/ # 
/ # cd /usr/local/nginx/html/
/usr/local/nginx/html # 
/usr/local/nginx/html # tar zcf baimei-games-all.tar.gz *
	
	
	2.拷贝配置文件及代码
[root@master231 classroomExercises]# kubectl cp baimei-games-002:/etc/nginx/conf.d/games.conf config/games.conf
[root@master231 classroomExercises]#
[root@master231 classroomExercises]# kubectl cp baimei-games-002:/usr/local/nginx/html/baimei-games-all.tar.gz softwares/baimei-games-all.tar.gz

	3.编写脚本并推送镜像
[root@master231 classroomExercises]# cat build.sh 
#!/bin/bash


docker build -t harbor.baimei.com/baimei-games/games:v0.5 .
docker push harbor.baimei.com/baimei-games/games:v0.5
[root@master231 classroomExercises]# 
[root@master231 classroomExercises]# ./build.sh 
赞(7)
未经允许不得转载:工具盒子 » 游戏镜像上K8S