openshift 中OC 命令来管理image 和container

今天周末在家实践了一下openshift 中OC 的命令:

1: 先发现oc 总是报没有配置的错误:

[root@test3 sysconfig]# oc status
error: Missing or incomplete configuration info.  Please login or point to an existing, complete config file:

  1. Via the command-line flag --config
  2. Via the KUBECONFIG environment variable
  3. In your home directory as ~/.kube/config

To view or setup config directly use the 'config' command.
后来登入后这个错误就消失了:

2: 下面开始先以 admin / admin 来登入:

# oc login -n openshift
Server [https://localhost:8443]: 
The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y

Authentication required for https://localhost:8443 (openshift)
Username: admin
Password: 
Login successful.

You don't have any projects. You can try to create a new project, by running

    oc new-project <projectname>

看到上面提示可以自己通过command 来新建一个project, 我就试试啦:
[root@test3 /]# oc new-project xinxin
Now using project "xinxin" on server "https://localhost:8443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git

to build a new example application in Ruby.
--

看到上面project : xinxin 已经建好了,我就尝试一下建application:

[root@test3 /]# oc get user
No resources found.
Error from server: User "dev" cannot list all users in the cluster
[root@test3 /]# oc logout
Logged "dev" out on "https://localhost:8443"

可以看到上面原来登入的是dev 用户,还是先切换到admin 用户来create application 吧:
[root@test3 /]# oc login
Authentication required for https://localhost:8443 (openshift)
Username: admin
Password: 
Login successful.

You have one project on this server: "xinxin"

Using project "xinxin".
 

3: 开始创建xinxin project 下面的 application:

[root@test3 /]# oc new-app openshift/hello-openshift
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
--> Found Docker image 7af3297 (17 months old) from Docker Hub for "openshift/hello-openshift"

    * An image stream will be created as "hello-openshift:latest" that will track this image
    * This image will be deployed in deployment config "hello-openshift"
    * Ports 8080/tcp, 8888/tcp will be load balanced by service "hello-openshift"
      * Other containers can access this service through the hostname "hello-openshift"

--> Creating resources ...
    imagestream "hello-openshift" created
    deploymentconfig "hello-openshift" created
    service "hello-openshift" created
--> Success
    WARNING: No Docker registry has been configured with the server. Automatic builds and deployments may not function.
    Run 'oc status' to view your app.
[root@test3 /]# 
下面开始登入到https://192.168.122.31:8843, 看到如下的application 已经在建立了:

4: 从server 层面来看一下status:

[root@test3 /]# oc get all
NAME                 DOCKER REPO   TAGS      UPDATED
is/hello-openshift                 latest    4 minutes ago
is/origin                          latest    5 minutes ago

NAME                 REVISION   DESIRED   CURRENT   TRIGGERED BY
dc/hello-openshift   1          1         1         config,image(hello-openshift:latest)
dc/origin            1          1         1         config,image(origin:latest)

NAME                   DESIRED   CURRENT   READY     AGE
rc/hello-openshift-1   1         1         1         4m
rc/origin-1            1         1         0         5m

NAME                  CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
svc/hello-openshift   172.30.71.65     <none>        8080/TCP,8888/TCP   4m
svc/origin            172.30.114.145   <none>        53/TCP,8443/TCP     6m

NAME                         READY     STATUS             RESTARTS   AGE
po/hello-openshift-1-xd2ka   1/1       Running            0          4m
po/origin-1-0os36            0/1       CrashLoopBackOff   5          5m
[root@test3 /]# 
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shenghuiping2001

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值