1. はじめに
現時点では、ibmcloud CLIは以下のように、Power Systems Virtual Servers(以下PowerVS)に対して、private endpoint接続(インターネットにアクセスすることなくAPI/CLIを呼び出す機能)には対応していない。
[root@new-syasuda-tok1-vpc1 ~]# ibmcloud plugin list
Listing installed plug-ins...
Plugin Name Version Status Private endpoints supported
cloud-databases 0.14.0 false
cloud-dns-services[dns/dns-svcs] 0.7.2 true
cloud-functions[wsk/functions/fn] 1.0.66 false
cloud-internet-services[cis] 1.14.11 true
cloud-object-storage 1.6.0 false
container-registry[cr] 1.0.6 true
container-service[kubernetes-service/ks] 1.0.498 false
hpcs 0.0.1 false
hpvs 1.4.24 false
key-protect 0.7.0 true
logging 0.0.8 false
power-iaas 0.4.6 false
privileged-access-gateway 1.2.6 false
schematics[sch] 1.12.8 true
tg-cli[tg] 0.8.10 true
tke 1.3.1 true
vpc-infrastructure[infrastructure-service/is] 6.10.0 true
しかし、APIに対してはprivate endpoint接続に対応している。
https://cloud.ibm.com/apidocs/power-cloud
重要なのは、このAPI private endpoint接続というのは、あくまでIBM CloudのClassic InfrastructureやVPCからのインターネットを利用しない接続を指しており、PowerVSからは利用できないことである。一般的にsnapshot機能やreplication機能などはAPI呼び出しでしか対応しておらず、できたらPowrVS上のサーバーから呼び出したい時も多い。この問題を解決するためには、PowerVSはClassic InfrastructureやVPCと、無償のDirect Linkで接続できるため、
PowerVS ---> Direct Link ---> Proxy Server on VPC ---> PowerVS private endpoint
のように、VPC上のVSI上でsquidなどを使ってProxy Serverを作成することである。これにより、PowreVSからインターネットに出ることなくPower VSのAPIにアクセスできる。
- IAM API private endpoint:
https://private.iam.cloud.ibm.com
- PowerVS API private endpoint:
https://private.${region}.power-iaas.cloud.ibm.com
本記事では、既にDirect Linkを敷設して、Proxy ServerをVPC上に構築済みであるという前提の上で、PowerVSからインターネットに出ることなくAPI呼び出しできることを確認する。
2. Private endpointのProxy経由のアクセス
bash-4.3# oslevel -s
7200-04-01-1939
bash-4.3# which curl
/opt/freeware/bin/curl
bash-4.3# which jq
/opt/freeware/bin/jq
bash-4.3# APIKEY=xxxxxxxxx
bash-4.3# export https_proxy=http://10.0.0.4:3128
bash-4.3# iam_token=`curl -skX POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=${APIKEY}" \
https://private.iam.cloud.ibm.com/identity/token | jq -r '.access_token' `
bash-4.3# CRN=crn:v1:bluemix:public:power-iaas:tok04:a/039dbe6794084c7cb514a276dd2345da:7bcf8f28-869c-4c3c-8955-a989a8d4406b::
bash-4.3# CLOUD_INSTANCE_ID=$(echo ${CRN} | cut -f 8 -d ":")
bash-4.3# region=jp-tok
bash-4.3# curl -skX GET https://private.${region}.power-iaas.cloud.ibm.com/pcloud/v1/cloud-instances/${CLOUD_INSTANCE_ID}/pvm-instances -H "Authorization: Bearer $iam_token" -H "CRN: ${CRN}" -H "Content-Type: application/json" | jq
{
"pvmInstances": [
{
"addresses": [
{
"href": "/pcloud/v1/cloud-instances/bd4124205da84b46b6c61e580f912b25/pvm-instances/d9c9cdb3-5b16-43d5-8fbe-0692c1dbac6d/networks/public-192_168_186_56-29-VLAN_2003",
"ip": "192.168.186.60",
"ipAddress": "192.168.186.60",
"macAddress": "fa:70:eb:c3:bd:20",
"networkName": "public-192_168_186_56-29-VLAN_2003",
"type": "fixed",
"version": 4
},
{
"href": "/pcloud/v1/cloud-instances/bd4124205da84b46b6c61e580f912b25/pvm-instances/d9c9cdb3-5b16-43d5-8fbe-0692c1dbac6d/networks/subnet-192-168-50-0",
"ip": "192.168.50.223",
"ipAddress": "192.168.50.223",
"macAddress": "fa:70:eb:c3:bd:21",
"networkName": "subnet-192-168-50-0",
"type": "fixed",
"version": 4
}
],
"creationDate": "2020-10-29T05:04:34.000Z",
"diskSize": 20,
"health": {
"lastUpdate": "2022-12-01T04:48:20.393367",
"status": "OK"
},
"hostID": 36,
"href": "/pcloud/v1/cloud-instances/bd4124205da84b46b6c61e580f912b25/pvm-instances/d9c9cdb3-5b16-43d5-8fbe-0692c1dbac6d",
"imageID": "b6b5a59b-271a-4c8e-9b14-d8651d0d6d98",
"maxmem": 4,
"maxproc": 2,
"memory": 2,
"minmem": 2,
"minproc": 0.5,
"networks": [
{
"href": "/pcloud/v1/cloud-instances/bd4124205da84b46b6c61e580f912b25/pvm-instances/d9c9cdb3-5b16-43d5-8fbe-0692c1dbac6d/networks/public-192_168_186_56-29-VLAN_2003",
"ip": "192.168.186.60",
"ipAddress": "192.168.186.60",
"macAddress": "fa:70:eb:c3:bd:20",
"networkName": "public-192_168_186_56-29-VLAN_2003",
"type": "fixed",
"version": 4
},
{
"href": "/pcloud/v1/cloud-instances/bd4124205da84b46b6c61e580f912b25/pvm-instances/d9c9cdb3-5b16-43d5-8fbe-0692c1dbac6d/networks/subnet-192-168-50-0",
"ip": "192.168.50.223",
"ipAddress": "192.168.50.223",
"macAddress": "fa:70:eb:c3:bd:21",
"networkName": "subnet-192-168-50-0",
"type": "fixed",
"version": 4
}
],
"operatingSystem": "AIX 7.2, 7200-04-01-1939",
"osType": "aix",
"pinPolicy": "none",
"placementGroup": "none",
"procType": "shared",
"processors": 1,
"pvmInstanceID": "d9c9cdb3-5b16-43d5-8fbe-0692c1dbac6d",
"serverName": "powervs1",
"srcs": [
[
{
"src": "00000000",
"timestamp": "2021-09-04T21:48:48Z"
}
]
],
"status": "ACTIVE",
"storagePool": "Tier3-Flash-1",
"storagePoolAffinity": true,
"storageType": "tier3",
"sysType": "s922",
"updatedDate": "2020-10-29T05:04:34.000Z",
"virtualCores": {
"assigned": 1,
"max": 4,
"min": 1
}
}
]
}