6.2. 安装 .NET 镜像流
要安装 .NET 镜像流,请使用带有 OpenShift Client (oc
)二进制文件的 s2i-dotnetcore 中的镜像流定义。镜像流可以从 Linux、Mac 和 Windows 安装。脚本可让您安装、更新或删除镜像流。
您可以在全局 openshift
命名空间中或本地定义 .NET 镜像流。更新 openshift
命名空间定义需要足够的权限。
6.2.1. 使用 OpenShift 客户端安装镜像流
您可以使用 OpenShift Client (oc
)安装 .NET 镜像流。
先决条件
- 命名空间中必须存在现有的 pull secret。如果命名空间中不存在 pull secret。按照 Red Hat Container Registry 身份验证 指南中的说明添加一个。
步骤
列出可用的 .NET 镜像流:
$ oc describe is dotnet
输出显示已安装的镜像。如果没有安装镜像,则会显示
Error from server (NotFound)
信息。如果显示
Error from server (NotFound)
信息:安装 .NET 镜像流:
$ oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams.json
如果没有显示
Error from server (NotFound)
信息:当已安装 .NET 镜像流时,您可以运行以下命令包括更新的版本:
$ oc replace -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams.json
6.2.2. 在 Linux 和 macOS 上安装镜像流
您可以使用此脚本在 Linux 和 macOS 上安装、升级或删除镜像流。
步骤
下载脚本。
对于 Linux 使用:
$ wget https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/install-imagestreams.sh
在 Mac 中使用:
$ curl https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/install-imagestreams.sh -o install-imagestreams.sh
使脚本可执行:
$ chmod +x install-imagestreams.sh
登录到 OpenShift 集群:
$ oc login
安装镜像流并添加针对
registry.redhat.io
进行身份验证的 pull secret:./install-imagestreams.sh --os rhel [--user subscription_username --password subscription_password]
使用用户名替换 subscription_username,并使用用户的密码替换 subscription_password。如果您不打算使用基于 RHEL7- 的镜像,可以省略凭据。
如果 pull secret 已存在,则
--user
和--password
参数将被忽略。
附加信息
-
./install-imagestreams.sh --help
6.2.3. 在 Windows 上安装镜像流
您可以使用此脚本在 Windows 上安装、升级或删除镜像流。
步骤
下载脚本。
Invoke-WebRequest https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/install-imagestreams.ps1 -UseBasicParsing -OutFile install-imagestreams.ps1
登录到 OpenShift 集群:
$ oc login
安装镜像流并添加针对
registry.redhat.io
进行身份验证的 pull secret:.\install-imagestreams.ps1 --OS rhel [-User subscription_username -Password subscription_password]
使用用户名替换 subscription_username,并使用用户的密码替换 subscription_password。如果您不打算使用基于 RHEL7- 的镜像,可以省略凭据。
如果 pull secret 已存在,则忽略
-User
和-Password
参数。
PowerShell ExecutionPolicy
可能会禁止执行此脚本。要放松策略,请运行 Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force
。
附加信息
-
Get-Help .\install-imagestreams.ps1