mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
cks: Fix provider deployment when cluster is in a project (#7147)
This commit is contained in:
parent
c774b865c9
commit
2d914edff0
@ -37,6 +37,7 @@ import com.cloud.network.Network;
|
|||||||
import com.cloud.network.Network.GuestType;
|
import com.cloud.network.Network.GuestType;
|
||||||
import com.cloud.network.NetworkModel;
|
import com.cloud.network.NetworkModel;
|
||||||
import com.cloud.network.dao.NetworkDao;
|
import com.cloud.network.dao.NetworkDao;
|
||||||
|
import com.cloud.projects.ProjectService;
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
import com.cloud.service.dao.ServiceOfferingDao;
|
||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
@ -137,6 +138,8 @@ public class KubernetesClusterActionWorker {
|
|||||||
protected VirtualMachineManager itMgr;
|
protected VirtualMachineManager itMgr;
|
||||||
@Inject
|
@Inject
|
||||||
protected LaunchPermissionDao launchPermissionDao;
|
protected LaunchPermissionDao launchPermissionDao;
|
||||||
|
@Inject
|
||||||
|
public ProjectService projectService;
|
||||||
|
|
||||||
protected KubernetesClusterDao kubernetesClusterDao;
|
protected KubernetesClusterDao kubernetesClusterDao;
|
||||||
protected KubernetesClusterVmMapDao kubernetesClusterVmMapDao;
|
protected KubernetesClusterVmMapDao kubernetesClusterVmMapDao;
|
||||||
@ -469,13 +472,17 @@ public class KubernetesClusterActionWorker {
|
|||||||
protected boolean createCloudStackSecret(String[] keys) {
|
protected boolean createCloudStackSecret(String[] keys) {
|
||||||
File pkFile = getManagementServerSshPublicKeyFile();
|
File pkFile = getManagementServerSshPublicKeyFile();
|
||||||
Pair<String, Integer> publicIpSshPort = getKubernetesClusterServerIpSshPort(null);
|
Pair<String, Integer> publicIpSshPort = getKubernetesClusterServerIpSshPort(null);
|
||||||
List<KubernetesClusterVmMapVO> vmMapVOList = getKubernetesClusterVMMaps();
|
|
||||||
publicIpAddress = publicIpSshPort.first();
|
publicIpAddress = publicIpSshPort.first();
|
||||||
sshPort = publicIpSshPort.second();
|
sshPort = publicIpSshPort.second();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final String command = String.format("sudo %s/%s -u '%s' -k '%s' -s '%s'",
|
String command = String.format("sudo %s/%s -u '%s' -k '%s' -s '%s'",
|
||||||
scriptPath, deploySecretsScriptFilename, ApiServiceConfiguration.ApiServletPath.value(), keys[0], keys[1]);
|
scriptPath, deploySecretsScriptFilename, ApiServiceConfiguration.ApiServletPath.value(), keys[0], keys[1]);
|
||||||
|
Account account = accountDao.findById(kubernetesCluster.getAccountId());
|
||||||
|
if (account != null && account.getType() == Account.Type.PROJECT) {
|
||||||
|
String projectId = projectService.findByProjectAccountId(account.getId()).getUuid();
|
||||||
|
command = String.format("%s -p '%s'", command, projectId);
|
||||||
|
}
|
||||||
Pair<Boolean, String> result = SshHelper.sshExecute(publicIpAddress, sshPort, getControlNodeLoginUser(),
|
Pair<Boolean, String> result = SshHelper.sshExecute(publicIpAddress, sshPort, getControlNodeLoginUser(),
|
||||||
pkFile, null, command, 10000, 10000, 60000);
|
pkFile, null, command, 10000, 10000, 60000);
|
||||||
return result.first();
|
return result.first();
|
||||||
|
|||||||
@ -24,6 +24,7 @@ Arguments:
|
|||||||
-u, --url string ID of the cluster
|
-u, --url string ID of the cluster
|
||||||
-k, --key string API Key
|
-k, --key string API Key
|
||||||
-s, --secret string Secret Key
|
-s, --secret string Secret Key
|
||||||
|
-p, --project string Project ID
|
||||||
Other arguments:
|
Other arguments:
|
||||||
-h, --help Display this help message and exit
|
-h, --help Display this help message and exit
|
||||||
Examples:
|
Examples:
|
||||||
@ -34,6 +35,8 @@ USAGE
|
|||||||
API_URL=""
|
API_URL=""
|
||||||
API_KEY=""
|
API_KEY=""
|
||||||
SECRET_KEY=""
|
SECRET_KEY=""
|
||||||
|
PROJECT_ID=""
|
||||||
|
PROJECT=""
|
||||||
while [ -n "$1" ]; do
|
while [ -n "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | --help)
|
-h | --help)
|
||||||
@ -51,6 +54,11 @@ while [ -n "$1" ]; do
|
|||||||
SECRET_KEY=$2
|
SECRET_KEY=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-p | --project)
|
||||||
|
PROJECT_ID=$2
|
||||||
|
shift 2
|
||||||
|
PROJECT="project-id = $PROJECT_ID"
|
||||||
|
;;
|
||||||
-*|*)
|
-*|*)
|
||||||
echo "ERROR: no such option $1. -h or --help for help"
|
echo "ERROR: no such option $1. -h or --help for help"
|
||||||
exit 1
|
exit 1
|
||||||
@ -62,7 +70,9 @@ cat > /tmp/cloud-config <<EOF
|
|||||||
api-url = $API_URL
|
api-url = $API_URL
|
||||||
api-key = $API_KEY
|
api-key = $API_KEY
|
||||||
secret-key = $SECRET_KEY
|
secret-key = $SECRET_KEY
|
||||||
|
$PROJECT
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create secret if not exists
|
# Create secret if not exists
|
||||||
/opt/bin/kubectl -n kube-system get secret cloudstack-secret || /opt/bin/kubectl -n kube-system create secret generic cloudstack-secret --from-file=/tmp/cloud-config
|
/opt/bin/kubectl -n kube-system get secret cloudstack-secret || /opt/bin/kubectl -n kube-system create secret generic cloudstack-secret --from-file=/tmp/cloud-config
|
||||||
rm /tmp/cloud-config
|
rm /tmp/cloud-config
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user