k8s初探:minikube创建一个jenkins应用

前提:要安装minikube搭建kubernetes集群

可以参考:https://www.cnblogs.com/Leo_wl/p/8526552.html 

完成后开始创建我们的应用

拉取官方最新的jenkins镜像

docker pull jenkins
C:\Kubernetes>docker pull jenkins
Using default tag: latest
latest: Pulling from library/jenkins
cc1a78bfd46b: Pull complete
6861473222a6: Pull complete
7e0b9c3b5ae0: Pull complete
3ec98735f56f: Pull complete
55160131808f: Pull complete
a8dbacf623ff: Pull complete
8145eb5a3756: Pull complete
e00673c707b5: Pull complete
b21012f36779: Pull complete
c6152a1d29ac: Pull complete
ae434261c51d: Pull complete
fd467134b3f8: Pull complete
b81c96ec9b6a: Pull complete
9b6548b0bd62: Pull complete
4ca52754e146: Pull complete
50dd39aed954: Pull complete
fcfb4b526bcf: Pull complete
f0ce5fe5e7bf: Pull complete
1d14df9562d0: Pull complete
2d050852b010: Pull complete
Digest: sha256:00bc27808eb97fe90d914ef51724d944b975d0f9eee105e11c5cda8ee379a401
Status: Downloaded newer image for jenkins:latest
查看镜像
C:\Kubernetes>docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
jenkins             latest              0f178e3827f0        9 days ago          798MB
nginx               latest              ae513a47849c        2 weeks ago         109MB

创建deployment

C:\Kubernetes> kubectl run jenkins --image=jenkins  --port=8080
deployment "jenkins" created

查看pod是否处于running状态

kubectl.exe get pod
C:\Kubernetes>kubectl get pod
NAME                      READY     STATUS              RESTARTS   AGE
hello-6dbbbb95d-5knjf     1/1       Running             0          27m
jenkins-f6466f7d4-c4f5j   0/1       ContainerCreating   0          1m

C:\Kubernetes>kubectl get pod
NAME                      READY     STATUS    RESTARTS   AGE
hello-6dbbbb95d-5knjf     1/1       Running   0          27m
jenkins-f6466f7d4-c4f5j   1/1       Running   0          1m

发布服务

C:\Kubernetes> kubectl expose deployment jenkins  --type=NodePort
service "jenkins" exposed

获取服务地址

C:\Kubernetes>minikube service jenkins --url
http://192.168.0.103:32346

然后就可以使用上面的地址在浏览器上访问

Warning: 

可能需要在容器中获取初始密码 

C:\Kubernetes>kubectl.exe get pod
NAME                      READY     STATUS    RESTARTS   AGE
hello-6dbbbb95d-5knjf     1/1       Running   0          29m
jenkins-f6466f7d4-c4f5j   1/1       Running   0          3m

C:\Kubernetes>kubectl.exe exec -it jenkins-f6466f7d4-c4f5j bash
jenkins@jenkins-f6466f7d4-c4f5j:/$ ll
bash: ll: command not found
jenkins@jenkins-f6466f7d4-c4f5j:/$ ls
bin  boot  dev  docker-java-home  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
jenkins@jenkins-f6466f7d4-c4f5j:/$ cat /var/jenkins_home/secrets/initialAdminPassword
3b4902f6ea084566b21e4bc1c1801f14
jenkins@jenkins-f6466f7d4-c4f5j:/$








阅读更多
下一篇ubuntu系统安装搜狗输入法
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭