精华内容
下载资源
问答
  • openshift教程_教程:掌握OpenShift

    千次阅读 2020-06-10 09:25:21
    本文将引导您完成使用OpenShift在Cloud中设置一台,两台,三台而不是五台新计算机所需的简单步骤。 您将部署应用程序以进行开发,测试或在数分钟之内将它们全面展示给全世界。 没有更多的混乱。 我们首先概述什么...

    openshift教程

    本文将引导您完成使用OpenShift在Cloud中设置一台,两台,三台而不是五台新计算机所需的简单步骤。 您将部署您的应用程序以进行开发,测试或在数分钟之内将它们全面展示给全世界。 没有更多的混乱。

    我们首先概述什么是OpenShift,它来自何处以及如何在工作站上获得客户端工具设置。 然后,您将带您了解适用于OpenShift的客户端工具。 几分钟之内,您便可以开始专注于应用程序开发,并在OpenShift中进行部署以对其进行测试。 完成后,您将只丢弃测试机器并继续前进。 此后,您将完全有能力在选择时,需要的地方并立即注意进入OpenShift Cloud。 这就是开发应该的样子,没有堆栈干扰的开发。

    现在,在IT世界中,有关云的宣传大肆宣传。 对于IaaS,PaaS和SaaS之类的各个领域,不乏首字母缩写词。 OpenShift是Red Hat的平台即服务(PaaS),它为您提供了运行应用程序的平台。 对于作为开发人员的您来说,您想要查看将应用程序作为仅提供的服务放置的环境。 您无需理会该服务如何由一组组件构造,如何配置或在何处运行。 您只想利用他们提供的此服务来部署,开发,测试和运行您的应用程序。 在此基本级别上,OpenShift为您的Java应用程序提供了一个平台。

    首先,让我们快速了解一下OpenShift的来源。 它始于一家总部位于加利福尼亚州红木城的名为Makara的公司,该公司提供的解决方案使组织能够在私有或公共云上部署,管理,监视和扩展其应用程序。 红帽于2010年11月收购了Makara,第二年他们将红帽技术合并到一个名为OpenShift的新项目中。

    最近,OpenShift团队宣布启动名为OpenShift Origin的开源项目,从而使整个代码库都可以在线获得。 您甚至可以使用它们提供的liveCD进行试用,但这不在本文讨论范围之内 。 对于Java开发人员来说,使这种技术融合有趣的是,Red Hat 在OpenShift中包含了基于JBoss AS 7的下一代应用程序平台。 这为您的所有开发需求带来了快速的闪电应用平台。

    OpenShift

    OpenShift网站指出:“ OpenShift是一个免费的基于云的应用程序平台,适用于Java,Perl,PHP,Python和Ruby应用程序。 它非常简单-您的开发环境也是您的部署环境:而且您在云中。” 这激起了人们的兴趣,因此让我们尝试一下,看看是否可以将我们的Web应用程序提升到云端。 为此,我们有jBPM Migration Web应用程序 ,在本练习的其余部分中,我们将使用它作为运行示例。

    OpenShift入门在网站上有很好的记录,可以作为快速入门,一旦您注册了Red Hat Cloud(rhcloud)帐户,便可以立即开始使用。 快速入门为我们提供了使我们的应用程序联机所需的四个步骤,并从安装必需的客户端工具开始。 这是针对Red Hat Enterprise Linux(RHEL),Fedora Linux,通用Linux发行版,Mac OS X和Windows概述的。 对于RHEL和Fedora,这是一个简单的软件包安装,而对于其余部分,则是基于Ruby的gem安装,我们将留给读者将其应用于他们的系统。

    一旦安装了客户端工具,就会有多个基于rhc- <command>形式的命令。 有可用的在线界面,但是大多数开发人员更喜欢命令行客户端工具提供的控件,因此我们将使用它们。 以下是对可用内容的概述,并简要介绍了每种内容。

    • rhc-create-domain –用于将注册的rhcloud用户绑定到rhcloud中的域。 每个注册的rhcloud用户最多可以有一个域。
    • rhc-create-app –用于为给定的rhcloud用户,给定的开发环境(Java,Ruby,Python,Perl,PHP)和给定的rhcloud域创建应用程序。 对于给定的域,您最多可以创建五个应用程序。 这将为您的rhcloud实例生成完整的URI,根据您选择的环境设置您的rhcloud实例,默认情况下将为您选择的开发环境创建本地git项目。
    • rhc-snapshot –用于创建给定rhcloud实例的本地备份。
    • rhc-ctl-app –用于控制给定的rhcloud应用程序。 您可以在此处添加数据库,检查实例的状态,启动,停止等。
    • rhc-tail-files –用于连接到rhcloud应用程序日志文件并将其转储到命令外壳中。
    • rhc-user-info –用于查看给定的rhcloud用户,定义的域和创建的应用程序。
    • rhc-chk –用于对安装程序进行简单的配置检查。

    建立您的网域

    要开始使用我们的演示应用程序,我们需要做一些简单的事情来获得一个OpenShift实例设置,以托管我们的Java应用程序,从域开始。

    # We need to create the domain for OpenShift to start setting up
    # our URL with the client tooling using
    # rhc-create-domain -n domainname -l rhlogin
    #
    $ rhc-create-domain –help
    Usage: /usr/bin/rhc-create-domain
    Bind a registered rhcloud user to a domain in rhcloud.
    NOTE: to change ssh key, please alter your ~/.ssh/libra_id_rsa and
    ~/.ssh/libra_id_rsa.pub key, then re-run with –alter
    -n|–namespace namespace Namespace for your application(s) (alphanumeric – max 16 chars) (required)
    -l|–rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift access) (required)
    -p|–password password RHLogin password (optional, will prompt)
    -a|–alter Alter namespace (will change urls) and/or ssh key
    -d|–debug Print Debug info
    -h|–help Show Usage info
    # So we setup one for our Java application. Note that we already have
    # setup my ssh keys for OpenShift, if you have not yet done that,
    # then it will walk you through it.
    #
    $ rhc-create-domain -n inthe -l [rhcloud-user] -p [mypassword]
    OpenShift key found at /home/[homedir]/.ssh/libra_id_rsa. Reusing…
    Contacting https://openshift.redhat.com
    Creation successful
    You may now create an application. Please make note of your local config file
    in /home/[homedir]/.openshift which has been created and populated for you.

    创建你的应用

    接下来,我们要创建应用程序,这意味着我们要告诉OpenShift我们需要哪个堆栈。 这是通过rhc-create-app客户端工具完成的。

    # Let’s take a look at the options available before we setup a Java
    # instance for our application.
    #
    $ rhc-create-app –help
    Contacting https://openshift.redhat.com to obtain list of cartridges…
    (please excuse the delay)
    Usage: /usr/bin/rhc-create-app
    Create an OpenShift app.
    -a|–app application Application name (alphanumeric – max 16 chars) (required)
    -t|–type type Type of app to create (perl-5.10, jbossas-7.0, wsgi-3.2, rack-1.1, php-5.3) (require)
    -l|–rhlogin rhlogin Red Hat login (RHN or OpenShift login) (Default: xxxxxxxxx)
    -p|–password password RHLogin password (optional, will prompt)
    -r|–repo path Git Repo path (defaults to ./$app_name)
    -n|–nogit Only create remote space, don’t pull it locally
    -d|–debug Print Debug info
    -h|–help Show Usage info
    # It seems we can choose between several but we want the jboss-as7.0
    # stack (called a cartridge). Provide a user, password and location
    # for the git repo to be created called ‘jbpmmigration’, see the
    # documentation for the defaults. Let’s watch the magic happen!
    #
    $ rhc-create-app -a jbpmmigration -t jbossas-7.0 -l [rhcloud-user] -p [mypassword] -r /home/[homedir]/git-projects/jbpmmigration
    Found a bug? Post to the forum and we’ll get right on it.
    IRC: #openshift on freenode
    Forums: https://www.redhat.com/openshift/forums
    Attempting to create remote application space: jbpmmigration
    Contacting https://openshift.redhat.com
    API version: 1.1.1
    Broker version: 1.1.1
    RESULT:
    Successfully created application: jbpmmigration
    Checking ~/.ssh/config
    Contacting https://openshift.redhat.com
    Found rhcloud.com in ~/.ssh/config… No need to adjust
    Now your new domain name is being propagated worldwide (this might take a minute)…
    Pulling new repo down
    Warning: Permanently added ‘jbpmmigration-inthe.rhcloud.com,50.17.167.44′ (RSA) to the list of known hosts.
    Confirming application jbpmmigration is available
    Attempt # 1
    Success! Your application is now published here:
    http://jbpmmigration-inthe.rhcloud.com/
    The remote repository is located here:
    ssh://1806d6b78bb844d49378874f222f4403@jbpmmigration-inthe.rhcloud.com/~/git/jbpmmigration.git/

    要更改您的应用程序,请提交到jbpmmigration /。 然后运行“ git push”以更新您的OpenShift空间。

    如果我们查看我给定的回购路径,就会发现一个git-projects / jbpmmigration git存储库。 请注意,如果您决定更改域名,则必须调整git repository配置文件以反映远程存储库的位置,请参见“ ssh:…..”行上方。 该页面也已经处于活动状态 http://jbpmmigration-ishereon.rhcloud.com/ 这只是一个入门的初始屏幕,因此现在我们继续部署现有的jBPM Migration项目。

    首先,让我们看一下git项目中提供的自述文件,该文件对存储库布局有一些见解。

    Repo layout
    ===========
    deployments/ – location for built wars (Details below)
    src/ – maven src structure
    pom.xml – maven build file
    .openshift/ – location for openshift specific files
    .openshift/config/ – location for configuration files such as standalone.xml (used to modify jboss config such as datasources)
    ../data – For persistent data (also in env var OPENSHIFT_DATA_DIR)
    .openshift/action_hooks/build – Script that gets run every push, just prior to starting your app

    对于本文,我们将仅检查部署和src目录。 您只需放入WAR文件,在项目根目录中删除pom.xml文件,它们就会被自动部署。 如果要部署爆炸的WAR文件,则只需添加README文件中概述的名为“ .dodeploy”的文件即可。 对于实际的项目开发,我们希望通过普通的src目录结构推送代码,也可以通过使用提供的pom.xml文件来实现。 提供的自述文件提供了开始使用所需的所有详细信息。

    我们的演示应用程序jbpmmigration还带有一个README文件,该文件提供了将项目内容添加到我们的新git存储库中的说明,因此我们将运行这些命令将这些文件拉入我们的本地项目中。

    # placing our application into our Openshift git repo.
    #
    $ cd jbpmmigration
    $ git remote add upstream -m master git://github.com/eschabell/openshift-jbpmmigration.git
    $ git pull -s recursive -X theirs upstream master
    # now we need to push the content.
    #
    $ git push origin
    [jbpmmigration maven build log output removed]
    remote: [INFO] ————————————————————————
    remote: [INFO] BUILD SUCCESS
    remote: [INFO] ————————————————————————
    remote: [INFO] Total time: 3.114s
    remote: [INFO] Finished at: Mon Nov 14 10:26:57 EST 2011
    remote: [INFO] Final Memory: 5M/141M
    remote: [INFO] ————————————————————————
    remote: ~/git/jbpmmigration.git
    remote: Running .openshift/action_hooks/build
    remote: Running .openshift/action_hooks/deploy
    remote: Starting application…
    remote: Done
    remote: Running .openshift/action_hooks/post_deploy
    To ssh://1806d6b78bb844d49378874f222f4403@jbpmmigration-inthe.rhcloud.com/~/git/jbpmmigration.git/410a1c9..7ea0003 master -> master

    如您所见,我们现在将内容推送到我们创建的rhcloud实例,它部署了内容并启动了我们的实例。 现在,我们应该可以在http://jbpmmigration-inthe.rhcloud.com/jbpmmigration_upload-0.2在线找到我们的应用程序。

    然后,最后一步是您已经完成了该应用程序的工作,并希望将其释放给新的应用程序。 然后,您可以使用rhc-snapshot >客户端工具进行备份,然后使用rhc-ctl-app客户端工具删除实例。

    # Ready to get rid of our application now.
    #
    $ rhc-ctl-app -a jbpmmigration -l eschabell -c destroy
    Password: ********
    Contacting https://openshift.redhat.com
    !!!! WARNING !!!! WARNING !!!! WARNING !!!!
    You are about to destroy the jbpmmigration application.
    This is NOT reversible, all remote data for this application will be removed.
    Do you want to destroy this application (y/n): y
    Contacting https://openshift.redhat.com
    API version: 1.1.1
    Broker version: 1.1.1
    RESULT: Successfully destroyed application: jbpmmigration

    结论

    如您所见,从应用程序开发中必须使用的五个免费实例开始非常容易。

    这就完成了我们对OpenShift项目的游览,在其中我们为您提供了等待您和您的应用程序的可能性的一瞥。 创建域,定义您的应用程序需求并将您的项目导入提供的git项目非常容易。 将更改推送到新实例后,您将关闭并在云中测试应用程序开发。 这是真的。 这很简单。 现在走到那里,将您的代码提升到云炒作之上。

    翻译自: https://jaxenter.com/tutorial-getting-to-grips-with-openshift-105161.html

    openshift教程

    展开全文
  • Java Spring微服务 在这个示例应用程序中,您将使用Spring创建一个基本的Java Web应用程序。 这提供了创建在运行的Java微服务应用程序的起点。 它不包含默认的应用程序代码,但具有标准的最佳实践,包括运行状况检查...
  • openshift.io / scc : restricted creationTimestamp : 2017 - 03 - 22 T03 : 11 : 05 Z generateName : parksmap - 1 - labels : app : parksmap deployment : parksmap - 1 deploymentconfig ...
    
    /**
     * 类描述信息
     *
     * @author Freddy Shen
     * @since 17/3/22
     */
    
        Last login: Tue Mar 21 20:32:00 on console
        UsertekiMacBook-Pro:~ user$ oc version
        oc v1.3.0
        kubernetes v1.3.0+52492b4
        features: Basic-Auth
        UsertekiMacBook-Pro:~ user$ oc login master.shanghai.openshift3roadshow.com
        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://master.shanghai.openshift3roadshow.com:443 (openshift)
        Username: user51
        Password:
        Login successful.
    
        You have one project on this server: "explore-51"
    
        Using project "explore-51".
        Welcome! See 'oc help' to get started.
                UsertekiMacBook-Pro:~ user$ oc project explore-51
        Already on project "explore-51" on server "https://master.shanghai.openshift3roadshow.com:443".
        UsertekiMacBook-Pro:~ user$ oc project
        Using project "explore-51" on server "https://master.shanghai.openshift3roadshow.com:443".
        UsertekiMacBook-Pro:~ user$ oc get pod
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-n8kik   1/1       Running   0          3m
        UsertekiMacBook-Pro:~ user$ oc get pod parksmap-1-n8kik -o yaml
        apiVersion: v1
        kind: Pod
        metadata:
        annotations:
        kubernetes.io/created-by: |
        {"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationController","namespace":"explore-51","name":"parksmap-1","uid":"2b4f2ccf-0ead-11e7-8803-0207258e034b","apiVersion":"v1","resourceVersion":"365915"}}
        kubernetes.io/limit-ranger: 'LimitRanger plugin set: cpu, memory request for container
        parksmap; cpu, memory limit for container parksmap'
        openshift.io/deployment-config.latest-version: "1"
        openshift.io/deployment-config.name: parksmap
        openshift.io/deployment.name: parksmap-1
        openshift.io/generated-by: OpenShiftWebConsole
        openshift.io/scc: restricted
        creationTimestamp: 2017-03-22T03:11:05Z
        generateName: parksmap-1-
        labels:
        app: parksmap
        deployment: parksmap-1
        deploymentconfig: parksmap
        name: parksmap-1-n8kik
        namespace: explore-51
        resourceVersion: "366152"
        selfLink: /api/v1/namespaces/explore-51/pods/parksmap-1-n8kik
        uid: 2fb3466b-0ead-11e7-8803-0207258e034b
        spec:
        containers:
                - image: docker.io/openshiftroadshow/parksmap@sha256:d6d321390e0c8db598b23bab6d65b126bf3d1e61a9de6515e3389951996c0369
        imagePullPolicy: IfNotPresent
        name: parksmap
        ports:
                - containerPort: 8080
        protocol: TCP
        resources:
        limits:
        cpu: "4"
        memory: 1Gi
        requests:
        cpu: 100m
        memory: 512Mi
        securityContext:
        capabilities:
        drop:
                - KILL
            - MKNOD
            - SETGID
            - SETUID
            - SYS_CHROOT
        privileged: false
        runAsUser: 1000580000
        seLinuxOptions:
        level: s0:c24,c14
        terminationMessagePath: /dev/termination-log
        volumeMounts:
                - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
        name: default-token-8gzh2
        readOnly: true
        dnsPolicy: ClusterFirst
        host: ip-192-199-0-77.ap-northeast-2.compute.internal
        imagePullSecrets:
                - name: default-dockercfg-gp3q0
        nodeName: ip-192-199-0-77.ap-northeast-2.compute.internal
        nodeSelector:
        env: user
        restartPolicy: Always
        securityContext:
        fsGroup: 1000580000
        seLinuxOptions:
        level: s0:c24,c14
        serviceAccount: default
        serviceAccountName: default
        terminationGracePeriodSeconds: 30
        volumes:
                - name: default-token-8gzh2
        secret:
        secretName: default-token-8gzh2
        status:
        conditions:
                - lastProbeTime: null
        lastTransitionTime: 2017-03-22T03:11:05Z
        status: "True"
        type: Initialized
      - lastProbeTime: null
        lastTransitionTime: 2017-03-22T03:11:30Z
        status: "True"
        type: Ready
      - lastProbeTime: null
        lastTransitionTime: 2017-03-22T03:11:05Z
        status: "True"
        type: PodScheduled
        containerStatuses:
                - containerID: docker://4382db63443c332b54a6c0fae758d733ae07341c785353409f96b4b2ad1bf478
        image: docker.io/openshiftroadshow/parksmap@sha256:d6d321390e0c8db598b23bab6d65b126bf3d1e61a9de6515e3389951996c0369
        imageID: docker-pullable://docker.io/openshiftroadshow/parksmap@sha256:d6d321390e0c8db598b23bab6d65b126bf3d1e61a9de6515e3389951996c0369
        lastState: {}
        name: parksmap
        ready: true
        restartCount: 0
        state:
        running:
        startedAt: 2017-03-22T03:11:29Z
        hostIP: 192.199.0.77
        phase: Running
        podIP: 10.1.26.3
        startTime: 2017-03-22T03:11:05Z
        UsertekiMacBook-Pro:~ user$ oc get services
        NAME       CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
        parksmap   172.30.102.141   <none>        8080/TCP   7m
        UsertekiMacBook-Pro:~ user$
        UsertekiMacBook-Pro:~ user$ oc get service parksmap -o yaml
        apiVersion: v1
        kind: Service
        metadata:
        annotations:
        openshift.io/generated-by: OpenShiftWebConsole
        creationTimestamp: 2017-03-22T03:10:56Z
        labels:
        app: parksmap
        name: parksmap
        namespace: explore-51
        resourceVersion: "365873"
        selfLink: /api/v1/namespaces/explore-51/services/parksmap
        uid: 2a9fc0fe-0ead-11e7-8803-0207258e034b
        spec:
        clusterIP: 172.30.102.141
        portalIP: 172.30.102.141
        ports:
                - name: 8080-tcp
        port: 8080
        protocol: TCP
        targetPort: 8080
        selector:
        deploymentconfig: parksmap
        sessionAffinity: None
        type: ClusterIP
        status:
        loadBalancer: {}
        UsertekiMacBook-Pro:~ user$
        UsertekiMacBook-Pro:~ user$ oc get pods -o wide
        NAME               READY     STATUS    RESTARTS   AGE       IP          NODE
        parksmap-1-n8kik   1/1       Running   0          12m       10.1.26.3   ip-192-199-0-77.ap-northeast-2.compute.internal
        UsertekiMacBook-Pro:~ user$ oc describe service parksmap
        Name:        parksmap
        Namespace:    explore-51
        Labels:          app=parksmap
        Selector:     deploymentconfig=parksmap
        Type:        ClusterIP
        IP:          172.30.102.141
        Port:        8080-tcp   8080/TCP
        Endpoints:    10.1.26.3:8080
        Session Affinity:  None
        No events.
        UsertekiMacBook-Pro:~ user$ oc get dc
        NAME       REVISION   DESIRED   CURRENT   TRIGGERED BY
        parksmap   1          1         1         config,image(parksmap:1.2.0)
        UsertekiMacBook-Pro:~ user$ oc get rc
        NAME         DESIRED   CURRENT   AGE
        parksmap-1   2         2         17m
        UsertekiMacBook-Pro:~ user$ oc describe svc parksmap
        Name:        parksmap
        Namespace:    explore-51
        Labels:          app=parksmap
        Selector:     deploymentconfig=parksmap
        Type:        ClusterIP
        IP:          172.30.102.141
        Port:        8080-tcp   8080/TCP
        Endpoints:    10.1.26.3:8080,10.1.32.5:8080
        Session Affinity:  None
        No events.
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-n8kik   1/1       Running   0          19m
        parksmap-1-uvjzr   1/1       Running   0          2m
        UsertekiMacBook-Pro:~ user$ oc delete pod parksmap-1-uvjzr
        pod "parksmap-1-uvjzr" deleted
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME               READY     STATUS              RESTARTS   AGE
        parksmap-1-f6rie   0/1       ContainerCreating   0          11s
        parksmap-1-n8kik   1/1       Running             0          20m
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-f6rie   1/1       Running   0          39s
        parksmap-1-n8kik   1/1       Running   0          20m
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-f6rie   1/1       Running   0          48s
        parksmap-1-n8kik   1/1       Running   0          20m
        UsertekiMacBook-Pro:~ user$ oc get routes
        UsertekiMacBook-Pro:~ user$ oc get services
        NAME       CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
        parksmap   172.30.102.141   <none>        8080/TCP   24m
        UsertekiMacBook-Pro:~ user$ oc expose service parksmap
        route "parksmap" exposed
        UsertekiMacBook-Pro:~ user$ oc get routes
        NAME       HOST/PORT                                                       PATH      SERVICES   PORT       TERMINATION
        parksmap   parksmap-explore-51.cloudapps.shanghai.openshift3roadshow.com             parksmap   8080-tcp
        UsertekiMacBook-Pro:~ user$ oc expose service --help
        Expose containers internally as services or externally via routes
    
        There is also the ability to expose a deployment configuration, replication controller, service, or pod
        as a new service on a specified port. If no labels are specified, the new object will re-use the
        labels from the object it exposes.
    
        Usage:
        oc expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type] [options]
    
        Examples:
                # Create a route based on service nginx. The new route will re-use nginx's labels
        oc expose service nginx
    
      # Create a route and specify your own label and route name
        oc expose service nginx -l name=myroute --name=fromdowntown
    
      # Create a route and specify a hostname
        oc expose service nginx --hostname=www.example.com
    
      # Expose a deployment configuration as a service and use the specified port
        oc expose dc ruby-hello-world --port=8080
    
                # Expose a service as a route in the specified path
        oc expose service nginx --path=/nginx
    
        Options:
                --container-port='': Synonym for --target-port
          --create-external-load-balancer=false: If true, create an external load balancer for this service (trumped by --type). Implementation is cloud provider dependent. Default is 'false'.
                --dry-run=false: If true, only print the object that would be sent, without sending it.
                --external-ip='': Additional external IP address (not managed by Kubernetes) to accept for the service. If this IP is routed to a node, the service can be accessed by this IP in addition to its generated service IP.
                -f, --filename=[]: Filename, directory, or URL to a file identifying the resource to expose a service
          --generator='': The name of the API generator to use.
                --hostname='': Set a hostname for the new route
      -l, --labels='': Labels to apply to the service created by this call.
          --load-balancer-ip='': IP to assign to to the Load Balancer. If empty, an ephemeral IP will be created and used (cloud-provider specific).
                --name='': The name for the newly created object.
                --no-headers=false: When using the default output, don't print headers.
                -o, --output='': Output format. One of: json|yaml|wide|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://releases.k8s.io/release-1.3/docs/user-guide/jsonpath.md].
                --output-version='': Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
                --overrides='': An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field.
          --path='': Set a path for the new route
          --port='': The port that the resource should serve on.
                --protocol='': The network protocol for the service to be created. Default is 'TCP'.
                --record=false: Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
      -R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
          --save-config=false: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future.
                --selector='': A label selector to use for this service. Only equality-based selector requirements are supported. If empty (the default) infer the selector from the replication controller or replica set.
                --session-affinity='': If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP'
                -a, --show-all=true: When printing, show all resources (false means hide terminated pods.)
          --show-labels=false: When printing, show all labels as the last column (default hide labels column)
          --sort-by='': If non-empty, sort list types using this field specification.  The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
          --target-port='': Name or number for the port on the container that the service should direct traffic to. Optional.
          --template='': Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
                --type='': Type for this service: ClusterIP, NodePort, or LoadBalancer. Default is 'ClusterIP'.
    
        Use "oc options" for a list of global command-line options (applies to all commands).
        UsertekiMacBook-Pro:~ user$ oc get routes
        NAME       HOST/PORT                                                       PATH      SERVICES   PORT       TERMINATION
        parksmap   parksmap-explore-51.cloudapps.shanghai.openshift3roadshow.com             parksmap   8080-tcp
        UsertekiMacBook-Pro:~ user$ oc get sa
        NAME       SECRETS   AGE
        builder    2         1d
        default    2         1d
        deployer   2         1d
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-6hvaz   1/1       Running   0          24m
        parksmap-1-n8kik   1/1       Running   0          47m
        UsertekiMacBook-Pro:~ user$ oc get pod
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-6hvaz   1/1       Running   0          24m
        parksmap-1-n8kik   1/1       Running   0          47m
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-6hvaz   1/1       Running   0          24m
        parksmap-1-n8kik   1/1       Running   0          47m
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-6hvaz   1/1       Running   0          1h
        parksmap-1-n8kik   1/1       Running   0          1h
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME               READY     STATUS    RESTARTS   AGE
        parksmap-1-6hvaz   1/1       Running   0          1h
        parksmap-1-n8kik   1/1       Running   0          2h
        UsertekiMacBook-Pro:~ user$ oc get all | grep natinal
    -bash: grep: command not found
        oc getUsertekiMacBook-Pro:~ user$ oc get all | grep national
    -bash: grep: command not found
    
    
    ^C
        UsertekiMacBook-Pro:~ user$ oc get all
    ^C
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME                    READY     STATUS    RESTARTS   AGE
        nationalparks-1-build   0/1       Error     0          2m
        parksmap-1-6hvaz        1/1       Running   0          1h
        parksmap-1-n8kik        1/1       Running   0          2h
        UsertekiMacBook-Pro:~ user$ oc get all |grep national
    -bash: grep: command not found
        UsertekiMacBook-Pro:~ user$ oc get all |grep national
    -bash: grep: command not found
    ^[[A^[[A^[[AUsertekiMacBook-Pro:~ user$ oc get pods
        UsertekiMacBook-Pro:~ user$ co get all
    -bash: co: command not found
        UsertekiMacBook-Pro:~ user$ oc get all
        NAME                       TYPE                                                                 FROM          LATEST
        bc/nationalparks           Source                                                               Git@master    1
        NAME                       TYPE                                                                 FROM          STATUS    STARTED         DURATION
        builds/nationalparks-1     Source                                                               Git@master    Failed    5 minutes ago   20s
        NAME                       DOCKER REPO                                                          TAGS          UPDATED
        is/nationalparks           172.30.150.128:5000/explore-51/nationalparks
        is/parksmap                172.30.150.128:5000/explore-51/parksmap                              1.2.0         2 hours ago
        NAME                       REVISION                                                             DESIRED       CURRENT   TRIGGERED BY
        dc/nationalparks           0                                                                    1             0         config,image(nationalparks:latest)
        dc/parksmap                1                                                                    2             2         config,image(parksmap:1.2.0)
        NAME                       DESIRED                                                              CURRENT       AGE
        rc/parksmap-1              2                                                                    2             2h
        NAME                       HOST/PORT                                                            PATH          SERVICES        PORT       TERMINATION
        routes/nationalparks       nationalparks-explore-51.cloudapps.shanghai.openshift3roadshow.com                 nationalparks   8080-tcp
        routes/parksmap            parksmap-explore-51.cloudapps.shanghai.openshift3roadshow.com                      parksmap        8080-tcp
        NAME                       CLUSTER-IP                                                           EXTERNAL-IP   PORT(S)         AGE
        svc/parksmap               172.30.102.141                                                       <none>        8080/TCP        2h
        NAME                       READY                                                                STATUS        RESTARTS        AGE
        po/nationalparks-1-build   0/1                                                                  Error         0               5m
        po/parksmap-1-6hvaz        1/1                                                                  Running       0               1h
        po/parksmap-1-n8kik        1/1                                                                  Running       0               2h
        UsertekiMacBook-Pro:~ user$ oc get all | grep national
    -bash: grep: command not found
        UsertekiMacBook-Pro:~ user$ oc delete bc/nationalparks dc/nationalparks routes/nationalparks po/nationalparks-1-build
        buildconfig "nationalparks" deleted
        deploymentconfig "nationalparks" deleted
        route "nationalparks" deleted
        Error from server: pods "nationalparks-1-build" not found
        UsertekiMacBook-Pro:~ user$ oc get all
        NAME                  DOCKER REPO                                                     TAGS          UPDATED
        is/nationalparks      172.30.150.128:5000/explore-51/nationalparks
        is/parksmap           172.30.150.128:5000/explore-51/parksmap                         1.2.0         2 hours ago
        NAME                  REVISION                                                        DESIRED       CURRENT   TRIGGERED BY
        dc/parksmap           1                                                               2             2         config,image(parksmap:1.2.0)
        NAME                  DESIRED                                                         CURRENT       AGE
        rc/parksmap-1         2                                                               2             2h
        NAME                  HOST/PORT                                                       PATH          SERVICES   PORT       TERMINATION
        routes/parksmap       parksmap-explore-51.cloudapps.shanghai.openshift3roadshow.com                 parksmap   8080-tcp
        NAME                  CLUSTER-IP                                                      EXTERNAL-IP   PORT(S)    AGE
        svc/parksmap          172.30.102.141                                                  <none>        8080/TCP   2h
        NAME                  READY                                                           STATUS        RESTARTS   AGE
        po/parksmap-1-6hvaz   1/1                                                             Running       0          2h
        po/parksmap-1-n8kik   1/1                                                             Running       0          2h
        UsertekiMacBook-Pro:~ user$ oc delete is/nationalparks
        imagestream "nationalparks" deleted
        UsertekiMacBook-Pro:~ user$ oc get all
        NAME                  DOCKER REPO                                                     TAGS          UPDATED
        is/parksmap           172.30.150.128:5000/explore-51/parksmap                         1.2.0         2 hours ago
        NAME                  REVISION                                                        DESIRED       CURRENT   TRIGGERED BY
        dc/parksmap           1                                                               2             2         config,image(parksmap:1.2.0)
        NAME                  DESIRED                                                         CURRENT       AGE
        rc/parksmap-1         2                                                               2             2h
        NAME                  HOST/PORT                                                       PATH          SERVICES   PORT       TERMINATION
        routes/parksmap       parksmap-explore-51.cloudapps.shanghai.openshift3roadshow.com                 parksmap   8080-tcp
        NAME                  CLUSTER-IP                                                      EXTERNAL-IP   PORT(S)    AGE
        svc/parksmap          172.30.102.141                                                  <none>        8080/TCP   2h
        NAME                  READY                                                           STATUS        RESTARTS   AGE
        po/parksmap-1-6hvaz   1/1                                                             Running       0          2h
        po/parksmap-1-n8kik   1/1                                                             Running       0          2h
        UsertekiMacBook-Pro:~ user$ oc get pods
        NAME                    READY     STATUS      RESTARTS   AGE
        nationalparks-1-build   0/1       Completed   0          8m
        nationalparks-1-rgl5k   1/1       Running     0          5m
        parksmap-1-6hvaz        1/1       Running     0          2h
        parksmap-1-n8kik        1/1       Running     0          2h
        UsertekiMacBook-Pro:~ user$ oc policy add-role-to-user view -z default
        UsertekiMacBook-Pro:~ user$ oc get dc
        Unable to connect to the server: dial tcp: i/o timeout
        UsertekiMacBook-Pro:~ user$
        UsertekiMacBook-Pro:~ user$
        UsertekiMacBook-Pro:~ user$ oc env dc nationalparks -e MONGODB_USER=mongodb -e MONGODB_PASSWORD=mongodb -e MONGODB_DATABASE=mongodb -e MONGODB_SERVER_HOST=mongodb
    
    
        deploymentconfig "nationalparks" updated
        UsertekiMacBook-Pro:~ user$
        UsertekiMacBook-Pro:~ user$
        UsertekiMacBook-Pro:~ user$ oc get dc nationalparks -o yaml
        apiVersion: v1
        kind: DeploymentConfig
        metadata:
        annotations:
        openshift.io/generated-by: OpenShiftWebConsole
        creationTimestamp: 2017-03-22T05:38:44Z
        generation: 4
        labels:
        app: nationalparks
        name: nationalparks
        namespace: explore-51
        resourceVersion: "411383"
        selfLink: /oapi/v1/namespaces/explore-51/deploymentconfigs/nationalparks
        uid: d05c4d4e-0ec1-11e7-8803-0207258e034b
        spec:
        replicas: 1
        selector:
        deploymentconfig: nationalparks
        strategy:
        resources: {}
        rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
        type: Rolling
        template:
        metadata:
        creationTimestamp: null
        labels:
        app: nationalparks
        deploymentconfig: nationalparks
        spec:
        containers:
                - env:
                - name: MONGODB_USER
        value: mongodb
            - name: MONGODB_PASSWORD
        value: mongodb
            - name: MONGODB_DATABASE
        value: mongodb
            - name: MONGODB_SERVER_HOST
        value: mongodb
        image: 172.30.150.128:5000/explore-51/nationalparks@sha256:2d3a3786c35b7da3bc5e0d1c0f182bd61bdc3ac990ee8f40484f934991e1ec88
        imagePullPolicy: Always
        name: nationalparks
        ports:
                - containerPort: 8080
        protocol: TCP
            - containerPort: 8443
        protocol: TCP
            - containerPort: 8778
        protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        dnsPolicy: ClusterFirst
        restartPolicy: Always
        securityContext: {}
        terminationGracePeriodSeconds: 30
        test: false
        triggers:
                - imageChangeParams:
        automatic: true
        containerNames:
                - nationalparks
        from:
        kind: ImageStreamTag
        name: nationalparks:latest
        namespace: explore-51
        lastTriggeredImage: 172.30.150.128:5000/explore-51/nationalparks@sha256:2d3a3786c35b7da3bc5e0d1c0f182bd61bdc3ac990ee8f40484f934991e1ec88
        type: ImageChange
      - type: ConfigChange
        status:
        availableReplicas: 1
        details:
        causes:
                - type: ConfigChange
        message: config change
        latestVersion: 2
        observedGeneration: 4
        replicas: 1
        updatedReplicas: 1
        UsertekiMacBook-Pro:~ user$ oc label route nationalparks type=parksmap-backend
        route "nationalparks" labeled
        UsertekiMacBook-Pro:~ user$ oc policy add-role-to-user edit -z jenkins
    
    
    下载地址:配置OC指令下载地址(mac版本的): openshift-origin-client-tools-v1.3.0-3ab7af3d097b57f933eccef684a714f2368804e7-mac
    百度云 链接: https://pan.baidu.com/s/1pLHdmx9 密码: rvqm
    

    展开全文
  • openshift安装教程

    千次阅读 2018-05-29 08:35:10
    实验环境 操作系统: Centos 7 x86_...openshift: openshift-origin-server-v3.9.0-191fece-linux-64bit.tar 安装步骤 &gt; Check that sysctl net.ipv4.ip_forward is set to 1. 修改 /etc/docker/daem...

    实验环境

    1. 操作系统: Centos 7 x86_64
    2. Docker: 17.03.2-ce
    3. openshift: openshift-origin-server-v3.9.0-191fece-linux-64bit.tar

    安装步骤

    1. > Check that sysctl net.ipv4.ip_forward is set to 1.
    2. 修改 /etc/docker/daemon.json 文件,样例如下,并重启docker 服务:
    {
      "registry-mirrors": ["https://7b3flks3.mirror.aliyuncs.com"],
     "insecure-registries": ["172.30.0.0/16"]
    }

    重启命令:systemctl daemon-reload&&systemctl restart docker

    1. 修改防火墙配置,如下:
    firewall-cmd --permanent --new-zone dockerc
    firewall-cmd --permanent --zone dockerc --add-source 172.17.0.0/16
    firewall-cmd --permanent --zone dockerc --add-port 8443/tcp
    firewall-cmd --permanent --zone dockerc --add-port 53/udp
    firewall-cmd --permanent --zone dockerc --add-port 8053/udp
    firewall-cmd --reload
    1. 解压程序包,并进入程序目录,执行以下命令
    #192.168.4.143 为你的本机地址,不设置的话,无法访问webconsole
    oc cluster up --public-hostname '192.168.4.143'
    展开全文
  • [Packt Publishing] OpenShift 实践教程 (英文版) [Packt Publishing] Implementing OpenShift (E-Book) ☆ 图书概要:☆ A fast-paced, practical guide for using OpenShift to deploy your own open source ...
  • 安装openshift 1、下载地址:https://github.com/openshift/origin/releases 3.11下载:https://github.com/openshift/origin/releases/tag/v3.11.0 2、上传到/opt目录 mv openshift-origin-server-v3.11.0-0cbc...

    安装openshift

    1、下载地址:https://github.com/openshift/origin/releases

    3.11下载:https://github.com/openshift/origin/releases/tag/v3.11.0

    2、上传到/opt目录

    mv openshift-origin-server-v3.11.0-0cbc58b-linux-64bit.tar.gz /opt
    

    3、解压

    cd /opt
    tar -zxvf openshift-origin-server-v3.11.0-0cbc58b-linux-64bit.tar.gz
    

    4、目录太长,创建一个软链接

    ln -s openshift-origin-server-v3.11.0-0cbc58b-linux-64bit /opt/openshift
    

    5、 修改/etc/profile,加入环境变量

    PATH=$PATH:/opt/openshift/
    

    执行生效

    source /etc/profile
    

    6、启动集群

    oc cluster up --skip-registry-check=true --public-hostname=”10.10.10.114”
    

    启动完成出现

    The server is accessible via web console at:
        https://10.10.10.114:8443
    
    You are logged in as:
        User:     developer
        Password: <any value>
    
    To login as administrator:
        oc login -u system:admin
    

    7、配置防火墙

    firewall-cmd --zone=public --add-port=8443/tcp --permanent
    

    重新载入防火墙

    firewall-cmd --reload
    

    8、浏览器访问 https:// 10.10.10.114:8443

    https://www.jianshu.com/p/dc0edfbbc5eb在这里插入图片描述

    用户名 developer 密码:developer

    参考连接:
    openshift官网
    openshift单机版安装
    openshift集群ansible安装
    Centos7 下安装openshift
    OpenShift介绍

    展开全文
  • 文章目录教程说明准备环境OpenShift 教程说明 本系列OpenShift的Servic Mesh教程是基于Red Hat提供的《Istio Tutorial》,将其在OpenShift 4.2.x环境中进行了验证并翻译成中文。 准备环境 OpenShift教程的...
  • Lab: Installing the OpenShift CLI 2 Lab: Exploring the CLI and Web Console 5 Lab: Deploy a Docker Image 8 Lab: Scaling and Self Healing 14 Lab:CreatingRoutes by Exposing Services 18 ......
  • APPUiO-OpenShift 4技术实验室 该技术实验室基于OpenShift 4。 介绍 平台即服务(PaaS)正在改变我们开发软件的方式。 Puzzle在技术实验室中介绍了OpenShift-Red Hat的容器平台。 开发人员亲身实践了将应用程序引入...
  • Openshift 安装使用教程

    千次阅读 2014-03-16 21:05:01
    OpenShift是红帽公司推出的一个云计算服务平台,开发人员可以用它来构建和发布web应用。Openshift广泛支持多种编程语言和框架,如Java,Ruby和PHP等。另外它还提供了多种集成开发工具如Eclipse integration,JBoss ...
  • Centos7中openshift_3.11单节点安装及配置开机自启详解 本次openshift安装使用最简单便捷的单节点安装,适用于本地开发及测试 openshift简介 OpenShift是红帽公司2015年开始推出的一个开源容器应用平台,是一款Paas...
  • OpenShift官方教程,有下载链接

    千次阅读 2017-03-22 21:28:53
    下载地址: http://download.csdn.net/detail/shenhonglei1234/9790368
  • 集群内部的docker registry ,即内部的Docker镜像仓库,通过以下步骤即可完成安装。 第一步:切换到default项目空间 ...oadm registry --config=/home/openshift.local.config/master/admin...
  • 教程将引导您逐步将代码推送到私有Git存储库,将其部署到IBM Cloud集群上的Red Hat OpenShift,然后自动进行构建和部署过程。 此外,您还将学习如何在OpenShift路由上公开应用程序,绑定自定义域,监视环境的运行...
  • 在平安科技接触到openshift技术后,出于对技术的热衷,决定写博客记录一下自己学习openshift的学习过程与所知所会,让更多的人能够从中受益。 这篇文章主要是介绍在openshift上如何安装mysql服务,并且后端使用...
  • OpenShift 4.x HOL教程汇总

    千次阅读 2020-03-23 23:50:58
    文章目录OpenShift Hands-on LabQuarkusGitOpsIstio Service Mesh系列Istio-TutorialService MeshKnatvie系列Knative入门Knative-...Hands-on Lab (0) - 教程说明和准备环境 Hands-on Lab (1) - 多种方法部署运行应...
  • Openshift

    千次阅读 2018-03-13 17:04:09
    OpenShift OpenShift是红帽的云开发平台即服务(PaaS)。自由和开放源码的云计算平台使开发人员能够创建、测试和运行他们的应用程序,并且可以把它们部署到云中。Openshift广泛支持多种编程语言和框架,如Java,...
  • 第一步 : 将系统服务账号router,加入privileged安全上下文 命令如下: oadm policy add-scc-to-user privileged system:serviceaccount:default:... 相关镜像 docker.io/openshift/origin-haproxy-router:v3.7.2

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,287
精华内容 514
关键字:

openshift教程