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.NetworkModel;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.projects.ProjectService;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
@ -137,6 +138,8 @@ public class KubernetesClusterActionWorker {
|
||||
protected VirtualMachineManager itMgr;
|
||||
@Inject
|
||||
protected LaunchPermissionDao launchPermissionDao;
|
||||
@Inject
|
||||
public ProjectService projectService;
|
||||
|
||||
protected KubernetesClusterDao kubernetesClusterDao;
|
||||
protected KubernetesClusterVmMapDao kubernetesClusterVmMapDao;
|
||||
@ -469,13 +472,17 @@ public class KubernetesClusterActionWorker {
|
||||
protected boolean createCloudStackSecret(String[] keys) {
|
||||
File pkFile = getManagementServerSshPublicKeyFile();
|
||||
Pair<String, Integer> publicIpSshPort = getKubernetesClusterServerIpSshPort(null);
|
||||
List<KubernetesClusterVmMapVO> vmMapVOList = getKubernetesClusterVMMaps();
|
||||
publicIpAddress = publicIpSshPort.first();
|
||||
sshPort = publicIpSshPort.second();
|
||||
|
||||
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]);
|
||||
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(),
|
||||
pkFile, null, command, 10000, 10000, 60000);
|
||||
return result.first();
|
||||
|
||||
@ -24,6 +24,7 @@ Arguments:
|
||||
-u, --url string ID of the cluster
|
||||
-k, --key string API Key
|
||||
-s, --secret string Secret Key
|
||||
-p, --project string Project ID
|
||||
Other arguments:
|
||||
-h, --help Display this help message and exit
|
||||
Examples:
|
||||
@ -34,6 +35,8 @@ USAGE
|
||||
API_URL=""
|
||||
API_KEY=""
|
||||
SECRET_KEY=""
|
||||
PROJECT_ID=""
|
||||
PROJECT=""
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
@ -51,6 +54,11 @@ while [ -n "$1" ]; do
|
||||
SECRET_KEY=$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"
|
||||
exit 1
|
||||
@ -62,7 +70,9 @@ cat > /tmp/cloud-config <<EOF
|
||||
api-url = $API_URL
|
||||
api-key = $API_KEY
|
||||
secret-key = $SECRET_KEY
|
||||
$PROJECT
|
||||
EOF
|
||||
|
||||
# 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
|
||||
rm /tmp/cloud-config
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user