minishift v1.28.0で良く使うminishiftコマンド覚書

よくよくお世話になっているコマンドから徒然と

詳細はこちらをご覧ください。
[OKD > Latest > Minishift > Command Reference > minishift ](https://docs.okd.io/latest/minishift/command-ref/minishift.html)

# minishift ssh
minishift内にsshします
docker psとかしたくなったらminishift sshです(´・ω・`)

```console
$ minishift ssh
[docker@minishift ~]$
```

# docker login
[Red Hat Container Catalog(RHCC)](https://access.redhat.com/containers/)などのdocker imageをPullする際にregistryにログインします。

```console
[tak@centos76 ~]$ minishift ssh
[docker@minishift ~]$ docker login registry.connect.redhat.com --username <username>
Password:<password>
Login Succeeded
```

# docker search
docker imageを検索します。
下は[Red Hat Container Catalog(RHCC)](https://access.redhat.com/containers/)の例
まずは上のログインをした後で

```console
[docker@minishift ~]$ docker search registry.connect.redhat.com/wordpress
INDEX        NAME                                                        DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
redhat.com   registry.connect.redhat.com/bitnami/wordpress-apache-php5   This WordPress container solution is optim...   0
redhat.com   registry.connect.redhat.com/bitnami/wordpress-apache-php7   This WordPress container solution is optim...   0
redhat.com   registry.connect.redhat.com/bitnami/wordpress-nginx-php5    This WordPress container solution is optim...   0
redhat.com   registry.connect.redhat.com/bitnami/wordpress-nginx-php7    This WordPress container solution is optim...   0
```

# docker pull
docker imageをローカル環境のdockerに取得します。
ログインが必要なRegistryの場合はあらかじめdocker loginしておきます。

```console
[docker@minishift ~]$ docker pull registry.connect.redhat.com/bitnami/wordpress-nginx-php7
Using default tag: latest
Trying to pull repository registry.connect.redhat.com/bitnami/wordpress-nginx-php7 ...
latest: Pulling from registry.connect.redhat.com/bitnami/wordpress-nginx-php7
367d84554057: Pull complete
:
119b0de383d9: Pull complete
Digest: sha256:7f9bef9632f2a9a87ff4c02ded5080d4048418d26913d3dacfb9cf1c6612ae04
Status: Downloaded newer image for registry.connect.redhat.com/bitnami/wordpress-nginx-php7:latest
```

# docker images
minishift内のdocker Imageを確認します。

```console
$ minishift ssh
[docker@minishift ~]$ docker images
REPOSITORY                                                 TAG                 IMAGE ID            CREATED             SIZE
docker.io/openshift/origin-node                            v3.11.0             438d61da63d1        20 hours ago        1.16 GB
docker.io/openshift/origin-control-plane                   v3.11.0             00f980c345c1        20 hours ago        825 MB
docker.io/openshift/origin-hyperkube                       v3.11.0             d65ee3cc9874        20 hours ago        506 MB
docker.io/openshift/origin-haproxy-router                  v3.11.0             316c2621011d        20 hours ago        407 MB
docker.io/openshift/origin-pod                             v3.11.0             045ddf827c75        20 hours ago        258 MB
docker.io/openshift/origin-deployer                        v3.11.0             d05e619aac21        20 hours ago        380 MB
docker.io/openshift/origin-hypershift                      v3.11.0             a777d85d24b9        20 hours ago        546 MB
docker.io/openshift/origin-cli                             v3.11.0             83d7b0b2f011        20 hours ago        380 MB
172.30.1.1:5000/openshift/mariadb                          <none>              5e784880fd90        2 weeks ago         458 MB
registry.access.redhat.com/rhscl/mariadb-101-rhel7         latest              a4deee8ed5a5        3 weeks ago         455 MB
registry.connect.redhat.com/bitnami/wordpress-nginx-php7   latest              2892cd4d344e        5 weeks ago         580 MB
docker.io/openshift/origin-web-console                     v3.11.0             be30b6cce5fa        2 months ago        339 MB
docker.io/openshift/origin-docker-registry                 v3.11.0             a0d5ad164395        2 months ago        305 MB
docker.io/openshift/origin-service-serving-cert-signer     v3.11               47dadf9d43b6        2 months ago        276 MB
```

# minishift logs
minishiftのログを参照するために利用します。
**-f**を付けるとtail -fと同じイメージとなります。

```console
$ minishift logs -f
```

# minishift oc-env
ocコマンドにPATHを通す際に利用します。

```console
$ eval $(minishift oc-env)
```

```console
$ minishift oc-env
export PATH="/home/tak/.minishift/cache/oc/v3.11.0/linux:$PATH"
# Run this command to configure your shell:
# eval $(minishift oc-env)
```

# oc login

minishift(openshift)にログインする

```console
$ oc login $(minishift ip):8443 -u system -p admin
Login successful.

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

    oc new-project <projectname>
```

```console
$ oc login $(minishift ip):8443 -u developer
Login successful.

You have one project on this server: "myproject"

Using project "myproject".
```

# oc whoami
現在ログインしているユーザを確認する

```console
$ oc whoami
system
```

クレデンシャルを確認するには`-t`を付けます。

```console
$ oc whoami -t
O8lC2QsDLR00JQdzf3JSUsfNA02LhfpRoGw****NXUY
```

# oc policy can-i --list

ログインしているユーザーができることが判ります。
> Command "can-i" is deprecated, use 'oc auth can-i'

なので今後無くなるコマンドらしいです。

```console
$ oc policy can-i --list
Command "can-i" is deprecated, use 'oc auth can-i'
VERBS              NON-RESOURCE URLS        RESOURCE NAMES   API GROUPS                     RESOURCES
[create]           []                       []               [authorization.k8s.io]         [selfsubjectaccessreviews]
[create]           []                       []               []                             [selfsubjectrulesreviews]
[create]           []                       []               [authorization.openshift.io]   [selfsubjectrulesreviews]
[create get]       []                       []               []                             [buildconfigs/webhooks]
:
```

# oc image-import

現在のプロジェクトにdocker imageをインポートする

```console
$ oc import-image python-36-rhel7:latest --from=registry.access.redhat.com/rhscl/python-36-rhel7 --confirm
imagestream.image.openshift.io/python-36-rhel7 imported

Name:           python-36-rhel7
Namespace:      myproject
Created:        26 hours ago
Labels:         <none>
Annotations:        openshift.io/image.dockerRepositoryCheck=2019-01-12T05:52:39Z
Docker Pull Spec:   172.30.1.1:5000/myproject/python-36-rhel7
Image Lookup:       local=false
Unique Images:      1
Tags:           1

latest
  tagged from registry.access.redhat.com/rhscl/python-36-rhel7

  * registry.access.redhat.com/rhscl/python-36-rhel7@sha256:bc3538e03e4b8c60dbeb806e02b24360a389bd65a12ff73f55328eedfbcdcb3e
      26 hours ago

Image Name: python-36-rhel7:latest
Docker Image:   registry.access.redhat.com/rhscl/python-36-rhel7@sha256:bc3538e03e4b8c60dbeb806e02b24360a389bd65a12ff73f55328eedfbcdcb3e
Name:       sha256:bc3538e03e4b8c60dbeb806e02b24360a389bd65a12ff73f55328eedfbcdcb3e
Created:    1 second ago
Annotations:    image.openshift.io/dockerLayersOrder=ascending
Image Size: 222.1MB in 5 layers
Layers:     75.72MB sha256:23113ae36f8e9d98b1423e44673979132dec59db2805e473e931d83548b0be82
        1.223kB sha256:d134b18b98b0d113b7b1194a60efceaa2c06eff41386d6c14b0e44bfe557eee8
        6.795MB sha256:e9c030a1a5e35aacb0fe94238025996b812bafcc8c1422a35d7bda1223da6e9e
        86.37MB sha256:784f9bf048226aaa367d5784fcf90628254eb9c6998d72e894a525c4399d4c38
        53.24MB sha256:8daef2dd454ce803baaa827469d1ef3c6e0342422f61bac311021a15fa4cf7ce
Image Created:  6 weeks ago
Author:     <none>
Arch:       amd64
Entrypoint: container-entrypoint
Command:    /bin/sh -c $STI_SCRIPTS_PATH/usage
Working Dir:    /opt/app-root/src
User:       1001
Exposes Ports:  8080/tcp
Docker Labels:  architecture=x86_64
        authoritative-source-url=registry.access.redhat.com
        build-date=2018-11-26T07:27:36.337423
        com.redhat.build-host=cpt-0010.osbs.prod.upshift.rdu2.redhat.com
        com.redhat.component=rh-python36-container
        description=Python 3.6 available as container is a base platform for building and running various Python 3.6 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
        distribution-scope=public
        io.k8s.description=Python 3.6 available as container is a base platform for building and running various Python 3.6 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
        io.k8s.display-name=Python 3.6
        io.openshift.expose-services=8080:http
        io.openshift.s2i.scripts-url=image:///usr/libexec/s2i
        io.openshift.tags=builder,python,python36,rh-python36
        io.s2i.scripts-url=image:///usr/libexec/s2i
        maintainer=SoftwareCollections.org <sclorg@redhat.com>
        name=rhscl/python-36-rhel7
        release=36
        summary=Platform for building and running Python 3.6 applications
        url=https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/python-36-rhel7/images/1-36
        usage=s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.6/test/setup-test-app/ rhscl/python-36-rhel7 python-sample-app
        vcs-ref=96351017867feb48429a2dc98ecdd27fc450960c
        vcs-type=git
        vendor=Red Hat, Inc.
        version=1
Environment:    PATH=/opt/app-root/src/.local/bin/:/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
        container=oci
        SUMMARY=Platform for building and running Python 3.6 applications
        DESCRIPTION=Python 3.6 available as container is a base platform for building and running various Python 3.6 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
        STI_SCRIPTS_URL=image:///usr/libexec/s2i
        STI_SCRIPTS_PATH=/usr/libexec/s2i
        APP_ROOT=/opt/app-root
        HOME=/opt/app-root/src
        BASH_ENV=/opt/app-root/etc/scl_enable
        ENV=/opt/app-root/etc/scl_enable
        PROMPT_COMMAND=. /opt/app-root/etc/scl_enable
        NODEJS_SCL=rh-nodejs8
        PYTHON_VERSION=3.6
        PYTHONUNBUFFERED=1
        PYTHONIOENCODING=UTF-8
        LC_ALL=en_US.UTF-8
        LANG=en_US.UTF-8
        PIP_NO_CACHE_DIR=off
```

# minishift docker-env

```console
$ eval $(minishift docker-env)
```

```console
$ minishift docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.42.208:2376"
export DOCKER_CERT_PATH="/home/tak/.minishift/certs"
# Run this command to configure your shell:
# eval $(minishift docker-env)
```

# minishift console
minishiftの管理画面のURLを確認する際に利用します。
optionの**--url**を省略するとデフォルトブラウザでGUI画面を開いてくれます。

```console
$ minishift console --url
https://192.168.42.208:8443/console
```
```console
[tak@centos76 ~]$ minishift console
Opening the OpenShift Web console in the default browser...
This tool has been deprecated, use 'gio open' instead.
See 'gio help open' for more info.

```

# minishift ip
minishiftの管理画面のIPを確認する際に利用します。

```console
$ oc login $(minishift ip):8443 -u <username> -p <password>
```

```console
$ minishift ip
192.168.42.208
```

# minishift start
minishiftを開始する場合に使用します。
マシンスペックに依存するかと思いますがかなり時間がかかります。


なお、起動する際にCPUコア数、Disk容量、Memory容量も指定できます。

```console
$ minishift start --cpu 2 --disksize 30GB --memory 4GB
```

今はこれらしいです。

```console
$ minishift start --cpu 2 --disk-size 30GB --memory 4GB
```


[OKD > Latest > Minishift > Command Reference > minishift start](https://docs.okd.io/latest/minishift/command-ref/minishift_start.html)

```console
$ minishift start
-- Starting profile 'minishift'
-- Check if deprecated options are used ... OK
-- Checking if https://github.com is reachable ... OK
-- Checking if requested OpenShift version 'v3.11.0' is valid ... OK
-- Checking if requested OpenShift version 'v3.11.0' is supported ... OK
-- Checking if requested hypervisor 'kvm' is supported on this platform ... OK
-- Checking if KVM driver is installed ...
   Driver is available at /usr/local/bin/docker-machine-driver-kvm ...
   Checking driver binary is executable ... OK
-- Checking if Libvirt is installed ... OK
-- Checking if Libvirt default network is present ... OK
-- Checking if Libvirt default network is active ... OK
-- Checking the ISO URL ... OK
-- Checking if provided oc flags are supported ... OK
-- Starting the OpenShift cluster using 'kvm' hypervisor ...
-- Starting Minishift VM ............................................................... OK
-- Checking for IP address ... OK
-- Checking for nameservers ... OK
-- Checking if external host is reachable from the Minishift VM ...
   Pinging 8.8.8.8 ... OK
-- Checking HTTP connectivity from the VM ...
   Retrieving http://minishift.io/index.html ... OK
-- Checking if persistent storage volume is mounted ... OK
-- Checking available disk space ... 30% used OK
-- Writing current configuration for static assignment of IP address ... WARN
-- OpenShift cluster will be configured with ...
   Version: v3.11.0
-- Copying oc binary from the OpenShift container image to VM ... OK
-- Starting OpenShift cluster ..........................................................................
Getting a Docker client ...
Checking if image openshift/origin-control-plane:v3.11.0 is available ...
Checking type of volume mount ...
Determining server IP ...
Using public hostname IP 192.168.42.208 as the host IP
Checking if OpenShift is already running ...
Checking for supported Docker version (=>1.22) ...
Checking if insecured registry is configured properly in Docker ...
Checking if required ports are available ...
Checking if OpenShift client is configured properly ...
Checking if image openshift/origin-control-plane:v3.11.0 is available ...
Starting OpenShift using openshift/origin-control-plane:v3.11.0 ...
I1216 06:47:05.873208    2168 flags.go:30] Running "create-kubelet-flags"
I1216 06:47:07.284465    2168 run_kubelet.go:49] Running "start-kubelet"
I1216 06:47:08.568525    2168 run_self_hosted.go:181] Waiting for the kube-apiserver to be ready ...
I1216 06:48:02.700444    2168 interface.go:26] Installing "kube-proxy" ...
I1216 06:48:02.701361    2168 interface.go:26] Installing "kube-dns" ...
I1216 06:48:02.701381    2168 interface.go:26] Installing "openshift-service-cert-signer-operator" ...
I1216 06:48:02.701394    2168 interface.go:26] Installing "openshift-apiserver" ...
I1216 06:48:02.701484    2168 apply_template.go:81] Installing "openshift-apiserver"
I1216 06:48:02.710024    2168 apply_template.go:81] Installing "kube-proxy"
I1216 06:48:02.712048    2168 apply_template.go:81] Installing "kube-dns"
I1216 06:48:02.714242    2168 apply_template.go:81] Installing "openshift-service-cert-signer-operator"
I1216 06:49:10.398219    2168 interface.go:41] Finished installing "kube-proxy" "kube-dns" "openshift-service-cert-signer-operator" "openshift-apiserver"
I1216 06:51:34.120047    2168 run_self_hosted.go:242] openshift-apiserver available
I1216 06:51:34.120095    2168 interface.go:26] Installing "openshift-controller-manager" ...
I1216 06:51:34.120131    2168 apply_template.go:81] Installing "openshift-controller-manager"
I1216 06:51:55.962517    2168 interface.go:41] Finished installing "openshift-controller-manager"
Adding default OAuthClient redirect URIs ...
Adding web-console ...
Adding registry ...
Adding router ...
Adding persistent-volumes ...
Adding centos-imagestreams ...
Adding sample-templates ...
I1216 06:51:56.271903    2168 interface.go:26] Installing "openshift-web-console-operator" ...
I1216 06:51:56.272013    2168 interface.go:26] Installing "openshift-image-registry" ...
I1216 06:51:56.272031    2168 interface.go:26] Installing "openshift-router" ...
I1216 06:51:56.272047    2168 interface.go:26] Installing "persistent-volumes" ...
I1216 06:51:56.272063    2168 interface.go:26] Installing "centos-imagestreams" ...
I1216 06:51:56.272079    2168 interface.go:26] Installing "sample-templates" ...
I1216 06:51:56.272288    2168 interface.go:26] Installing "sample-templates/mongodb" ...
I1216 06:51:56.272315    2168 interface.go:26] Installing "sample-templates/mysql" ...
I1216 06:51:56.272338    2168 interface.go:26] Installing "sample-templates/dancer quickstart" ...
I1216 06:51:56.272362    2168 interface.go:26] Installing "sample-templates/django quickstart" ...
I1216 06:51:56.272390    2168 interface.go:26] Installing "sample-templates/sample pipeline" ...
I1216 06:51:56.272408    2168 interface.go:26] Installing "sample-templates/mariadb" ...
I1216 06:51:56.272424    2168 interface.go:26] Installing "sample-templates/postgresql" ...
I1216 06:51:56.272439    2168 interface.go:26] Installing "sample-templates/cakephp quickstart" ...
I1216 06:51:56.272487    2168 interface.go:26] Installing "sample-templates/nodejs quickstart" ...
I1216 06:51:56.272506    2168 interface.go:26] Installing "sample-templates/rails quickstart" ...
I1216 06:51:56.272550    2168 interface.go:26] Installing "sample-templates/jenkins pipeline ephemeral" ...
I1216 06:51:56.272715    2168 apply_list.go:67] Installing "sample-templates/jenkins pipeline ephemeral"
I1216 06:51:56.273678    2168 apply_template.go:81] Installing "openshift-web-console-operator"
I1216 06:51:56.286251    2168 apply_list.go:67] Installing "sample-templates/sample pipeline"
I1216 06:51:56.286420    2168 apply_list.go:67] Installing "sample-templates/mariadb"
I1216 06:51:56.287242    2168 apply_list.go:67] Installing "sample-templates/postgresql"
I1216 06:51:56.288229    2168 apply_list.go:67] Installing "centos-imagestreams"
I1216 06:51:56.288297    2168 apply_list.go:67] Installing "sample-templates/cakephp quickstart"
I1216 06:51:56.289110    2168 apply_list.go:67] Installing "sample-templates/mongodb"
I1216 06:51:56.289120    2168 apply_list.go:67] Installing "sample-templates/nodejs quickstart"
I1216 06:51:56.289500    2168 apply_list.go:67] Installing "sample-templates/mysql"
I1216 06:51:56.289655    2168 apply_list.go:67] Installing "sample-templates/rails quickstart"
I1216 06:51:56.289836    2168 apply_list.go:67] Installing "sample-templates/dancer quickstart"
I1216 06:51:56.290253    2168 apply_list.go:67] Installing "sample-templates/django quickstart"
I1216 06:53:03.603324    2168 interface.go:41] Finished installing "sample-templates/mongodb" "sample-templates/mysql" "sample-templates/dancer quickstart" "sample-templates/django quickstart" "sample-templates/sample pipeline" "sample-templates/mariadb" "sample-templates/postgresql" "sample-templates/cakephp quickstart" "sample-templates/nodejs quickstart" "sample-templates/rails quickstart" "sample-templates/jenkins pipeline ephemeral"
I1216 06:53:09.598711    2168 interface.go:41] Finished installing "openshift-web-console-operator" "openshift-image-registry" "openshift-router" "persistent-volumes" "centos-imagestreams" "sample-templates"
Server Information ...
OpenShift server started.

The server is accessible via web console at:
    https://192.168.42.208:8443/console


```
# minishift status
minishiftのステータスを確認する場合に使用します。

```console
$ minishift status
Minishift:  Running
Profile:    minishift
OpenShift:  Running (openshift v3.11.0+8de5c34-71)
DiskUsage:  30% of 19G (Mounted On: /mnt/sda1)
CacheUsage: 483.2 MB (used by oc binary, ISO or cached images)
```

# minishift stop
minishiftを停止する場合に使用します。

```console
$ minishift stop
Stopping the OpenShift cluster...
Cluster stopped.
```

# oc get templates

oc getにはいろいろオプションがありますが、Templateの一覧を取得する際に以下の様に使います。

```console
[tak@centos76 ~]$ oc get -n openshift templates
NAME                       DESCRIPTION                                                                        PARAMETERS        OBJECTS
cakephp-mysql-persistent   An example CakePHP application with a MySQL database. For more information ab...   20 (4 blank)      9
dancer-mysql-persistent    An example Dancer application with a MySQL database. For more information abo...   17 (5 blank)      9
django-psql-persistent     An example Django application with a PostgreSQL database. For more informatio...   20 (5 blank)      9
jenkins-ephemeral          Jenkins service, without persistent storage....                                    7 (all set)       6
jenkins-pipeline-example   This example showcases the new Jenkins Pipeline integration in OpenShift,...       16 (4 blank)      8
mariadb-persistent         MariaDB database service, with persistent storage. For more information about...   9 (3 generated)   4
mongodb-persistent         MongoDB database service, with persistent storage. For more information about...   9 (3 generated)   4
mysql-persistent           MySQL database service, with persistent storage. For more information about u...   9 (3 generated)   4
nodejs-mongo-persistent    An example Node.js application with a MongoDB database. For more information...    19 (4 blank)      9
postgresql-persistent      PostgreSQL database service, with persistent storage. For more information ab...   8 (2 generated)   4
rails-pgsql-persistent     An example Rails application with a PostgreSQL database. For more information...   21 (4 blank)      9
```
# oc process [template]

templateのyamlをこっそり覗き見るのに使いました。

```console
[tak@centos76 ~]$ oc process -o yaml openshift//django-psql-persistent
apiVersion: v1
items:
- apiVersion: v1
  kind: Secret
  metadata:
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: django-psql-persistent
  stringData:
    database-password: 8a74Ugowqaf4xlYr
    database-user: django
    django-secret-key: cnSmwaIZke99uhWyIt5avHUkyE0AmZXn4pG1jGVOV1Ex28fft7
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      description: Exposes and load balances the application pods
      service.alpha.openshift.io/dependencies: '[{"name": "postgresql", "kind": "Service"}]'
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: django-psql-persistent
  spec:
    ports:
    - name: web
      port: 8080
      targetPort: 8080
    selector:
      name: django-psql-persistent
- apiVersion: route.openshift.io/v1
  kind: Route
  metadata:
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: django-psql-persistent
  spec:
    host: ""
    to:
      kind: Service
      name: django-psql-persistent
- apiVersion: image.openshift.io/v1
  kind: ImageStream
  metadata:
    annotations:
      description: Keeps track of changes in the application image
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: django-psql-persistent
- apiVersion: build.openshift.io/v1
  kind: BuildConfig
  metadata:
    annotations:
      description: Defines how to build the application
      template.alpha.openshift.io/wait-for-ready: "true"
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: django-psql-persistent
  spec:
    output:
      to:
        kind: ImageStreamTag
        name: django-psql-persistent:latest
    postCommit:
      script: ./manage.py test
    source:
      contextDir: ""
      git:
        ref: ""
        uri: https://github.com/sclorg/django-ex.git
      type: Git
    strategy:
      sourceStrategy:
        env:
        - name: PIP_INDEX_URL
          value: ""
        from:
          kind: ImageStreamTag
          name: python:3.6
          namespace: openshift
      type: Source
    triggers:
    - type: ImageChange
    - type: ConfigChange
    - github:
        secret: CWPHdc8YOO6eJ1yxHADmMHi6OAmXaLMWotf0wtGW
      type: GitHub
- apiVersion: apps.openshift.io/v1
  kind: DeploymentConfig
  metadata:
    annotations:
      description: Defines how to deploy the application server
      template.alpha.openshift.io/wait-for-ready: "true"
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: django-psql-persistent
  spec:
    replicas: 1
    selector:
      name: django-psql-persistent
    strategy:
      type: Recreate
    template:
      metadata:
        labels:
          name: django-psql-persistent
        name: django-psql-persistent
      spec:
        containers:
        - env:
          - name: DATABASE_SERVICE_NAME
            value: postgresql
          - name: DATABASE_ENGINE
            value: postgresql
          - name: DATABASE_NAME
            value: default
          - name: DATABASE_USER
            valueFrom:
              secretKeyRef:
                key: database-user
                name: django-psql-persistent
          - name: DATABASE_PASSWORD
            valueFrom:
              secretKeyRef:
                key: database-password
                name: django-psql-persistent
          - name: APP_CONFIG
            value: ""
          - name: DJANGO_SECRET_KEY
            valueFrom:
              secretKeyRef:
                key: django-secret-key
                name: django-psql-persistent
          image: ' '
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 30
            timeoutSeconds: 3
          name: django-psql-persistent
          ports:
          - containerPort: 8080
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 3
            timeoutSeconds: 3
          resources:
            limits:
              memory: 512Mi
    triggers:
    - imageChangeParams:
        automatic: true
        containerNames:
        - django-psql-persistent
        from:
          kind: ImageStreamTag
          name: django-psql-persistent:latest
      type: ImageChange
    - type: ConfigChange
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: postgresql
  spec:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 1Gi
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      description: Exposes the database server
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: postgresql
  spec:
    ports:
    - name: postgresql
      port: 5432
      targetPort: 5432
    selector:
      name: postgresql
- apiVersion: apps.openshift.io/v1
  kind: DeploymentConfig
  metadata:
    annotations:
      description: Defines how to deploy the database
      template.alpha.openshift.io/wait-for-ready: "true"
    labels:
      app: django-psql-persistent
      template: django-psql-persistent
    name: postgresql
  spec:
    replicas: 1
    selector:
      name: postgresql
    strategy:
      type: Recreate
    template:
      metadata:
        labels:
          name: postgresql
        name: postgresql
      spec:
        containers:
        - env:
          - name: POSTGRESQL_USER
            valueFrom:
              secretKeyRef:
                key: database-user
                name: django-psql-persistent
          - name: POSTGRESQL_PASSWORD
            valueFrom:
              secretKeyRef:
                key: database-password
                name: django-psql-persistent
          - name: POSTGRESQL_DATABASE
            value: default
          image: ' '
          livenessProbe:
            exec:
              command:
              - /usr/libexec/check-container
              - --live
            initialDelaySeconds: 120
            timeoutSeconds: 10
          name: postgresql
          ports:
          - containerPort: 5432
          readinessProbe:
            exec:
              command:
              - /usr/libexec/check-container
            initialDelaySeconds: 5
            timeoutSeconds: 1
          resources:
            limits:
              memory: 512Mi
          volumeMounts:
          - mountPath: /var/lib/pgsql/data
            name: postgresql-data
        volumes:
        - name: postgresql-data
          persistentVolumeClaim:
            claimName: postgresql
    triggers:
    - imageChangeParams:
        automatic: true
        containerNames:
        - postgresql
        from:
          kind: ImageStreamTag
          name: postgresql:9.6
          namespace: openshift
      type: ImageChange
    - type: ConfigChange
kind: List
metadata: {}
```

# minishift addons list

minishiftにインストールされているadd-onの状態を確認します。

```console
$ minishift addons list
- admin-user                     : enabled  P(0)
- admissions-webhook             : disabled P(0)
- anyuid                         : disabled P(0)
- che                            : disabled P(0)
- redhat-registry-login          : disabled P(0)
- registry-route                 : disabled P(0)
- htpasswd-identity-provider     : disabled P(0)
- xpaas                          : disabled P(0)
```

# minishift addons enable

minishiftにインストールされているAdd-onを有効化します。
有効化するだけですので、下の`apply`をする必要があります。

```console
$ minishift addons enable admin-user
Add-on 'admin-user' enabled
```

# minishift addons apply

minishiftで有効化したAdd-onを適用します。これをしないとAdd-onが稼働しません。

```console
$ minishift addons apply admin-user
-- Applying addon 'admin-user':..
```

# minishift config view

minishiftのconfigに定義されている値を確認します。

```console
$ minishift config view
- disk-size                          : 30GB
- iso-url                            : centos
```

# minishift config set

minishiftのconfigに値をセットします。複数の値をセットする際は`,`区切りで定義します。

```console
$ minishift config set addon-env REGISTRY_USERNAME=username,REGISTRY_PASSWORD=password
```

```console
$ minishift config view
- addon-env                          : [REGISTRY_USERNAME=username REGISTRY_PASSWORD=password]
- disk-size                          : 30GB
- iso-url                            : centos
```


# その他
使ってく度に記載していきます♪