CentOS7のCodeReady Containers 1.7 を 1.11にUpdateする（OpenShift4.3.1→4.4.5）

# はじめに

目を離していたらCodeReady Containersが 1.7から1.11に(笑)
ということでまずは環境をアップデートします。

- OS: CentOS7 with GNOME Desktop
- CodeReady Containers 1.7　→　1.11

ちなみにCodeReady Container 1.11はOpenShift 4.4.5だそうです。


# まずはマニュアルを確認

[2.4. Upgrading CodeReady Containers](https://access.redhat.com/documentation/en-us/red_hat_codeready_containers/1.11/html/getting_started_guide/installation_gsg#upgrading-codeready-containers_gsg)

既にProjectがありPodがある場合、YAMLやコマンドから再作成できるようにしておいてください。
CodeReady Containerを一度削除するため、消えてしまいます。

## 1. Download the latest release of CodeReady Containers.

RedhatのDLページより最新のCodeReady ContainerをDLします。
[Code Ready Containers](https://cloud.redhat.com/openshift/install/crc/installer-provisioned)

```
[tak@minishift4 ~]$ cd /tmp
[tak@minishift4 tmp]$ curl -S https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz -o /tmp/crc-linux-amd64.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2078M  100 2078M    0     0  14.0M      0  0:02:27  0:02:27 --:--:-- 14.4M
```

ダウンロード出来たら解凍します。

```
[tak@minishift4 tmp]$ xz  -dc /tmp/crc-linux-amd64.tar.xz | tar xfv -
crc-linux-1.11.0-amd64/
crc-linux-1.11.0-amd64/LICENSE
crc-linux-1.11.0-amd64/doc.pdf
crc-linux-1.11.0-amd64/crc
```

ここでバージョン念のため確認してみましょう。

今のバージョン
OpenShiftは4.3.1

```
[tak@minishift4 tmp]$ crc version
crc version: 1.7.0+fa7e558
OpenShift version: 4.3.1 (embedded in binary)
```

ダウンロードしてきたCodeReady Containerのバージョン
OpenShift4.4.5となっていますね。

```
[tak@minishift4 tmp]$ cd crc-linux-1.11.0-amd64/
[tak@minishift4 crc-linux-1.11.0-amd64]$ ./crc version
crc version: 1.11.0+883ca49
OpenShift version: 4.4.5 (embedded in binary)
```

## 2. Delete the existing CodeReady Containers virtual machine:

> WARNING
The crc delete command results in the loss of data stored in the CodeReady Containers virtual machine. Save any desired information stored in the virtual machine before running this command.

今現状は環境整備しただけなのでわたしは構わず消しちゃいます。

```
[tak@minishift4 tmp]$ cd ~
[tak@minishift4 ~]$ crc delete
Do you want to delete the OpenShift cluster? [y/N]: y
Deleted the OpenShift cluster
```

## 3. Replace the earlier `crc` binary with the binary of the latest release. Verify that the new `crc` binary is in use by checking its version:

今の`crc`の場所を確認し置き換えます。
わたしはファイルに権限与えていますが、権限がない場合はsudoしてください。

```
[tak@minishift4 ~]$ which crc
/usr/local/bin/crc
[tak@minishift4 ~]$ cd /tmp
[tak@minishift4 tmp]$ cd crc-linux-1.11.0-amd64/
[tak@minishift4 crc-linux-1.11.0-amd64]$ ls
LICENSE  crc  doc.pdf
[tak@minishift4 crc-linux-1.11.0-amd64]$ cp -p crc /usr/local/bin/
```

バージョン確認を行います。

```
[tak@minishift4 crc-linux-1.11.0-amd64]$ cd ~
[tak@minishift4 ~]$ crc version
crc version: 1.11.0+883ca49
OpenShift version: 4.4.5 (embedded in binary)
```

はい。大丈夫ですね！

## 4. Set up the new CodeReady Containers release:

CodeReady Containerのセットアップを行います。
途中でsudoするのにパスワードが聞かれます。

```
[tak@minishift4 ~]$ crc setup
INFO Checking if oc binary is cached              
INFO Caching oc binary                            
INFO Checking if podman remote binary is cached   
INFO Checking if goodhosts binary is cached       
INFO Caching goodhosts binary                     
INFO Will use root access: change ownership of /home/tak/.crc/bin/goodhosts 
[sudo] tak のパスワード:
INFO Will use root access: set suid for /home/tak/.crc/bin/goodhosts 
INFO Checking if CRC bundle is cached in '$HOME/.crc' 
INFO Unpacking bundle from the CRC binary         
INFO Checking if running as non-root              
INFO Checking if Virtualization is enabled        
INFO Checking if KVM is enabled                   
INFO Checking if libvirt is installed             
INFO Checking if user is part of libvirt group    
INFO Checking if libvirt is enabled               
INFO Checking if libvirt daemon is running        
INFO Checking if a supported libvirt version is installed 
INFO Checking if crc-driver-libvirt is installed  
INFO Installing crc-driver-libvirt                
INFO Checking for obsolete crc-driver-libvirt     
INFO Checking if libvirt 'crc' network is available 
INFO Checking if libvirt 'crc' network is active  
INFO Checking if NetworkManager is installed      
INFO Checking if NetworkManager service is running 
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists 
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists 
Setup is complete, you can now run 'crc start' to start the OpenShift cluster
```

## 5. Start the new CodeReady Containers virtual machine:

さていよいよ起動です。
起動初回は「Image pull secret」を聞かれますのでダウンロードまたはクリップボードにCopyしておきます。
Pull Secretはダウンロードページ([Code Ready Containers](https://cloud.redhat.com/openshift/install/crc/installer-provisioned))下部にあります。

![2020-06-06.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/324255/0e44318f-34b7-79e0-1a1d-ff6bfb1f7ac5.png)

```
[tak@minishift4 ~]$ crc start
INFO Checking if oc binary is cached              
INFO Checking if podman remote binary is cached   
INFO Checking if goodhosts binary is cached       
INFO Checking if running as non-root              
INFO Checking if Virtualization is enabled        
INFO Checking if KVM is enabled                   
INFO Checking if libvirt is installed             
INFO Checking if user is part of libvirt group    
INFO Checking if libvirt is enabled               
INFO Checking if libvirt daemon is running        
INFO Checking if a supported libvirt version is installed 
INFO Checking if crc-driver-libvirt is installed  
INFO Checking if libvirt 'crc' network is available 
INFO Checking if libvirt 'crc' network is active  
INFO Checking if NetworkManager is installed      
INFO Checking if NetworkManager service is running 
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists 
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists 
? Image pull secret [? for help] **************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

INFO Extracting bundle: crc_libvirt_4.4.5.crcbundle ... 
INFO Checking size of the disk image /home/tak/.crc/cache/crc_libvirt_4.4.5/crc.qcow2 ... 
INFO Creating CodeReady Containers VM for OpenShift 4.4.5... 
INFO CodeReady Containers VM is running           
INFO Verifying validity of the cluster certificates ... 
INFO Check internal and public DNS query ...      
INFO Check DNS query from host ...                
INFO Generating new SSH key                       
INFO Copying kubeconfig file to instance dir ...  
INFO Starting OpenShift kubelet service           
INFO Configuring cluster for first start          
INFO Adding user's pull secret ...                
INFO Updating cluster ID ...                      
INFO Starting OpenShift cluster ... [waiting 3m]  
INFO                                              
INFO To access the cluster, first set up your environment by following 'crc oc-env' instructions 
INFO Then you can access it by running 'oc login -u developer -p developer https://api.crc.testing:6443' 
INFO To login as an admin, run 'oc login -u kubeadmin -p 8rynV-SeYLc-h8Ij7-YPYcz https://api.crc.testing:6443' 
INFO                                              
INFO You can now run 'crc console' and use these credentials to access the OpenShift web console 
Started the OpenShift cluster
WARN The cluster might report a degraded or error state. This is expected since several operators have been disabled to lower the resource usage. For more information, please consult the documentation 
[tak@minishift4 ~]$ 
```

ちょっとWARNでちゃいましたけど…汗

## WebConsoleの確認

Web Consoleにアクセスします。

```
[tak@minishift4 ~]$ crc 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.

```

ちょっとイメージが変わりましたね。

![2020-06-06 (1).png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/324255/c519e90d-740e-e339-eecb-6e418600f2b8.png)

![2020-06-06 (2).png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/324255/24ece585-0ad7-a889-d69b-9ea88d09c1d7.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/324255/1367c958-99ed-e0ee-1d86-0ee177e3a1f3.png)

ご対面～っと思ったらWeb Console死んじゃいました(笑)
もう一度時間をおいてアクセス！

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/324255/aea82478-bf3f-1782-f029-75eb29c10ed9.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/324255/542c2f90-e6ef-f8ec-659f-014cee435ad0.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/324255/5cbb28f2-0208-c241-9288-9aa5a87150c1.png)


とりあえずこれで環境構築は完了です。
YAML勉強しなきゃー汗