Skip to content

Commit 1c0b123

Browse files
committed
This PR/commit comprises of the following:
- Support to fallback on the older systemVM template in case of no change in template across ACS versions - Update core user to cloud in CKS - Display details of accessing CKS nodes in the UI - K8s Access tab - Update systemvm template from debian 11 to debian 11.2 - Update letsencrypt cert - Remove docker dependency as from ACS 4.16 onward k8s has deprecated support for docker - use containerd as container runtime
1 parent c86b98e commit 1c0b123

23 files changed

Lines changed: 173 additions & 160 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ tools/cli/cloudmonkey/precache.py
4848
tools/marvin/marvin/cloudstackAPI/
4949
tools/marvin/build/
5050
tools/cli/build/
51+
tools/appliance/systemvmtemplate/packer_cache/
5152
*.jar
5253
*.war
5354
*.mar

agent/src/main/java/com/cloud/agent/AgentShell.java

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@
1616
// under the License.
1717
package com.cloud.agent;
1818

19+
import com.cloud.agent.Agent.ExitStatus;
20+
import com.cloud.agent.dao.StorageComponent;
21+
import com.cloud.agent.dao.impl.PropertiesStorage;
22+
import com.cloud.resource.ServerResource;
23+
import com.cloud.utils.LogUtils;
24+
import com.cloud.utils.NumbersUtil;
25+
import com.cloud.utils.ProcessUtil;
26+
import com.cloud.utils.PropertiesUtil;
27+
import com.cloud.utils.backoff.BackoffAlgorithm;
28+
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
29+
import com.cloud.utils.exception.CloudRuntimeException;
30+
import com.google.common.base.Strings;
31+
import org.apache.commons.daemon.Daemon;
32+
import org.apache.commons.daemon.DaemonContext;
33+
import org.apache.commons.daemon.DaemonInitException;
34+
import org.apache.commons.lang.math.NumberUtils;
35+
import org.apache.log4j.Logger;
36+
import org.apache.log4j.xml.DOMConfigurator;
37+
38+
import javax.naming.ConfigurationException;
1939
import java.io.File;
2040
import java.io.FileNotFoundException;
2141
import java.io.IOException;
@@ -30,28 +50,6 @@
3050
import java.util.Properties;
3151
import java.util.UUID;
3252

33-
import javax.naming.ConfigurationException;
34-
35-
import org.apache.commons.daemon.Daemon;
36-
import org.apache.commons.daemon.DaemonContext;
37-
import org.apache.commons.daemon.DaemonInitException;
38-
import org.apache.commons.lang.math.NumberUtils;
39-
import org.apache.log4j.Logger;
40-
import org.apache.log4j.xml.DOMConfigurator;
41-
42-
import com.cloud.agent.Agent.ExitStatus;
43-
import com.cloud.agent.dao.StorageComponent;
44-
import com.cloud.agent.dao.impl.PropertiesStorage;
45-
import com.cloud.resource.ServerResource;
46-
import com.cloud.utils.LogUtils;
47-
import com.cloud.utils.NumbersUtil;
48-
import com.cloud.utils.ProcessUtil;
49-
import com.cloud.utils.PropertiesUtil;
50-
import com.cloud.utils.backoff.BackoffAlgorithm;
51-
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
52-
import com.cloud.utils.exception.CloudRuntimeException;
53-
import com.google.common.base.Strings;
54-
5553
public class AgentShell implements IAgentShell, Daemon {
5654
private static final Logger s_logger = Logger.getLogger(AgentShell.class.getName());
5755

@@ -423,13 +421,13 @@ private void launchAgentFromClassInfo(String resourceClassNames) throws Configur
423421
} catch (final ClassNotFoundException e) {
424422
throw new ConfigurationException("Resource class not found: " + name + " due to: " + e.toString());
425423
} catch (final SecurityException e) {
426-
throw new ConfigurationException("Security excetion when loading resource: " + name + " due to: " + e.toString());
424+
throw new ConfigurationException("Security exception when loading resource: " + name + " due to: " + e.toString());
427425
} catch (final NoSuchMethodException e) {
428-
throw new ConfigurationException("Method not found excetion when loading resource: " + name + " due to: " + e.toString());
426+
throw new ConfigurationException("Method not found exception when loading resource: " + name + " due to: " + e.toString());
429427
} catch (final IllegalArgumentException e) {
430-
throw new ConfigurationException("Illegal argument excetion when loading resource: " + name + " due to: " + e.toString());
428+
throw new ConfigurationException("Illegal argument exception when loading resource: " + name + " due to: " + e.toString());
431429
} catch (final InstantiationException e) {
432-
throw new ConfigurationException("Instantiation excetion when loading resource: " + name + " due to: " + e.toString());
430+
throw new ConfigurationException("Instantiation exception when loading resource: " + name + " due to: " + e.toString());
433431
} catch (final IllegalAccessException e) {
434432
throw new ConfigurationException("Illegal access exception when loading resource: " + name + " due to: " + e.toString());
435433
} catch (final InvocationTargetException e) {

engine/schema/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
</goals>
7474
<configuration>
7575
<source>
76-
def projectVersion = project.version
76+
def projectVersion = project.properties['project.systemvm.template.version']
7777
String[] versionParts = projectVersion.tokenize('.')
78-
pom.properties['cs.version'] = "4.16"
79-
pom.properties['patch.version'] = "0"
78+
pom.properties['cs.version'] = versionParts[0] + "." + versionParts[1]
79+
pom.properties['patch.version'] = versionParts[2]
8080
</source>
8181
</configuration>
8282
</execution>
@@ -146,7 +146,7 @@
146146
<executable>bash</executable>
147147
<arguments>
148148
<argument>templateConfig.sh</argument>
149-
<armument>${project.version}</armument>
149+
<argument>${project.systemvm.template.version}</argument>
150150
</arguments>
151151
</configuration>
152152
</execution>

engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,11 @@ public void check() {
367367
return;
368368
}
369369

370-
SystemVmTemplateRegistration.parseMetadataFile();
371-
final CloudStackVersion currentVersion = CloudStackVersion.parse(currentVersionValue);
372-
SystemVmTemplateRegistration.CS_MAJOR_VERSION = String.valueOf(currentVersion.getMajorRelease()) + "." + String.valueOf(currentVersion.getMinorRelease());
373-
SystemVmTemplateRegistration.CS_TINY_VERSION = String.valueOf(currentVersion.getPatchRelease());
370+
String csVersion = SystemVmTemplateRegistration.parseMetadataFile();
371+
final CloudStackVersion sysVmVersion = CloudStackVersion.parse(csVersion);
372+
final CloudStackVersion currentVersion = CloudStackVersion.parse(currentVersionValue);
373+
SystemVmTemplateRegistration.CS_MAJOR_VERSION = String.valueOf(sysVmVersion.getMajorRelease()) + "." + String.valueOf(sysVmVersion.getMinorRelease());
374+
SystemVmTemplateRegistration.CS_TINY_VERSION = String.valueOf(sysVmVersion.getPatchRelease());
374375

375376
s_logger.info("DB version = " + dbVersion + " Code Version = " + currentVersion);
376377

engine/schema/src/main/java/com/cloud/upgrade/SystemVmTemplateRegistration.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.cloud.upgrade.dao.BasicTemplateDataStoreDaoImpl;
3737
import com.cloud.user.Account;
3838
import com.cloud.utils.DateUtil;
39+
import com.cloud.utils.EncryptionUtil;
3940
import com.cloud.utils.Pair;
4041
import com.cloud.utils.UriUtils;
4142
import com.cloud.utils.db.GlobalLock;
@@ -54,7 +55,6 @@
5455
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
5556
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
5657
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
57-
import org.apache.commons.codec.digest.DigestUtils;
5858
import org.apache.commons.lang3.StringUtils;
5959
import org.apache.log4j.Logger;
6060
import org.ini4j.Ini;
@@ -64,7 +64,6 @@
6464
import java.io.File;
6565
import java.io.FileReader;
6666
import java.io.IOException;
67-
import java.io.InputStream;
6867
import java.net.URI;
6968
import java.nio.file.Files;
7069
import java.nio.file.Path;
@@ -351,16 +350,6 @@ public static boolean validateIfSeeded(String url, String path) {
351350
}
352351
}
353352

354-
private String calculateChecksum(File file) {
355-
try (InputStream is = Files.newInputStream(Paths.get(file.getPath()))) {
356-
return DigestUtils.md5Hex(is);
357-
} catch (IOException e) {
358-
String errMsg = "Failed to calculate template checksum";
359-
LOGGER.error(errMsg, e);
360-
throw new CloudRuntimeException(errMsg, e);
361-
}
362-
}
363-
364353
public Long getRegisteredTemplateId(Pair<Hypervisor.HypervisorType, String> hypervisorAndTemplateName) {
365354
VMTemplateVO vmTemplate = vmTemplateDao.findLatestTemplateByName(hypervisorAndTemplateName.second());
366355
Long templateId = null;
@@ -690,7 +679,7 @@ public void registerTemplate(Pair<Hypervisor.HypervisorType, String> hypervisorA
690679
}
691680
}
692681

693-
public static void parseMetadataFile() {
682+
public static String parseMetadataFile() {
694683
try {
695684
Ini ini = new Ini();
696685
ini.load(new FileReader(METADATA_FILE));
@@ -702,6 +691,8 @@ public static void parseMetadataFile() {
702691
NewTemplateChecksum.put(hypervisorType, section.get("checksum"));
703692
NewTemplateUrl.put(hypervisorType, section.get("downloadurl"));
704693
}
694+
Ini.Section section = ini.get("default");
695+
return section.get("version");
705696
} catch (Exception e) {
706697
String errMsg = String.format("Failed to parse systemVM template metadata file: %s", METADATA_FILE);
707698
LOGGER.error(errMsg, e);
@@ -735,7 +726,7 @@ private void validateTemplates(Set<Hypervisor.HypervisorType> hypervisorsInUse)
735726
}
736727

737728
File tempFile = new File(TEMPLATES_PATH + matchedTemplate);
738-
String templateChecksum = calculateChecksum(tempFile);
729+
String templateChecksum = EncryptionUtil.calculateChecksum(tempFile);
739730
if (!templateChecksum.equals(NewTemplateChecksum.get(getHypervisorType(hypervisor)))) {
740731
LOGGER.error(String.format("Checksum mismatch: %s != %s ", templateChecksum, NewTemplateChecksum.get(getHypervisorType(hypervisor))));
741732
templatesFound = false;
@@ -812,9 +803,6 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
812803
private void updateRegisteredTemplateDetails(Long templateId, Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName) {
813804
VMTemplateVO templateVO = vmTemplateDao.findById(templateId);
814805
templateVO.setTemplateType(Storage.TemplateType.SYSTEM);
815-
if (Hypervisor.HypervisorType.VMware == templateVO.getHypervisorType()) {
816-
templateVO.setDeployAsIs(true);
817-
}
818806
boolean updated = vmTemplateDao.update(templateVO.getId(), templateVO);
819807
if (!updated) {
820808
String errMsg = String.format("updateSystemVmTemplates:Exception while updating template with id %s to be marked as 'system'", templateId);

engine/schema/src/main/resources/META-INF/db/schema-41600to41610.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
--;
2121

2222
ALTER TABLE `cloud`.`vm_work_job` ADD COLUMN `secondary_object` char(100) COMMENT 'any additional item that must be checked during queueing' AFTER `vm_instance_id`;
23+
UPDATE `cloud`.`vm_template` set deploy_as_is = 0 where id = 8;

engine/schema/templateConfig.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ function getTemplateVersion() {
2323
subversion1="$(cut -d'.' -f1 <<<"$version")"
2424
subversion2="$(cut -d'.' -f2 <<<"$version")"
2525
minorversion="$(cut -d'.' -f3 <<<"$version")"
26+
securityversion="$(cut -d'.' -f4 <<<"$version")"
2627
export CS_VERSION="${subversion1}"."${subversion2}"
2728
export CS_MINOR_VERSION="${minorversion}"
29+
export VERSION="${CS_VERSION}.${CS_MINOR_VERSION}"
2830
}
2931

3032
function getGenericName() {
@@ -52,12 +54,14 @@ function getChecksum() {
5254

5355
function createMetadataFile() {
5456
local fileData=$(cat $SOURCEFILE)
57+
echo -e "["default"]\nversion = $VERSION.${securityversion}\n" >> $METADATAFILE
5558
for i in "${!templates[@]}"
5659
do
5760
section="$i"
5861
hvName=$(getGenericName $i)
59-
templatename="systemvm-${i}-${CS_VERSION}.${CS_MINOR_VERSION}"
60-
checksum=$(getChecksum "$fileData" $hvName)
62+
63+
templatename="systemvm-${i}-${VERSION}"
64+
checksum=$(getChecksum "$fileData" "$VERSION-$hvName")
6165
downloadurl="${templates[$i]}"
6266
filename=$(echo ${downloadurl##*'/'})
6367
echo -e "["$section"]\ntemplatename = $templatename\nchecksum = $checksum\ndownloadurl = $downloadurl\nfilename = $filename\n" >> $METADATAFILE
@@ -66,12 +70,12 @@ function createMetadataFile() {
6670

6771
declare -A templates
6872
getTemplateVersion $1
69-
templates=( ["kvm"]="https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-${CS_VERSION}.${CS_MINOR_VERSION}-kvm.qcow2.bz2"
70-
["vmware"]="https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-${CS_VERSION}.${CS_MINOR_VERSION}-vmware.ova"
71-
["xenserver"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$CS_VERSION.$CS_MINOR_VERSION-xen.vhd.bz2"
72-
["hyperv"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$CS_VERSION.$CS_MINOR_VERSION-hyperv.vhd.zip"
73-
["lxc"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$CS_VERSION.$CS_MINOR_VERSION-kvm.qcow2.bz2"
74-
["ovm3"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$CS_VERSION.$CS_MINOR_VERSION-ovm.raw.bz2" )
73+
templates=( ["kvm"]="https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-kvm.qcow2.bz2"
74+
["vmware"]="https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-vmware.ova"
75+
["xenserver"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-xen.vhd.bz2"
76+
["hyperv"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-hyperv.vhd.zip"
77+
["lxc"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-kvm.qcow2.bz2"
78+
["ovm3"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-ovm.raw.bz2" )
7579

7680

7781
PARENTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/dist/systemvm-templates/"

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,6 @@
1717

1818
package com.cloud.kubernetes.cluster.actionworkers;
1919

20-
import java.io.BufferedWriter;
21-
import java.io.File;
22-
import java.io.FileWriter;
23-
import java.io.IOException;
24-
import java.util.ArrayList;
25-
import java.util.Collections;
26-
import java.util.List;
27-
import java.util.Objects;
28-
29-
import javax.inject.Inject;
30-
31-
import org.apache.cloudstack.api.ApiConstants;
32-
import org.apache.cloudstack.ca.CAManager;
33-
import org.apache.cloudstack.config.ApiServiceConfiguration;
34-
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
35-
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
36-
import org.apache.commons.collections.CollectionUtils;
37-
import org.apache.commons.io.IOUtils;
38-
import org.apache.log4j.Level;
39-
import org.apache.log4j.Logger;
40-
4120
import com.cloud.dc.DataCenterVO;
4221
import com.cloud.dc.dao.DataCenterDao;
4322
import com.cloud.dc.dao.VlanDao;
@@ -82,10 +61,29 @@
8261
import com.cloud.vm.VirtualMachineManager;
8362
import com.cloud.vm.dao.UserVmDao;
8463
import com.google.common.base.Strings;
64+
import org.apache.cloudstack.api.ApiConstants;
65+
import org.apache.cloudstack.ca.CAManager;
66+
import org.apache.cloudstack.config.ApiServiceConfiguration;
67+
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
68+
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
69+
import org.apache.commons.collections.CollectionUtils;
70+
import org.apache.commons.io.IOUtils;
71+
import org.apache.log4j.Level;
72+
import org.apache.log4j.Logger;
73+
74+
import javax.inject.Inject;
75+
import java.io.BufferedWriter;
76+
import java.io.File;
77+
import java.io.FileWriter;
78+
import java.io.IOException;
79+
import java.util.ArrayList;
80+
import java.util.Collections;
81+
import java.util.List;
82+
import java.util.Objects;
8583

8684
public class KubernetesClusterActionWorker {
8785

88-
public static final String CLUSTER_NODE_VM_USER = "core";
86+
public static final String CLUSTER_NODE_VM_USER = "cloud";
8987
public static final int CLUSTER_API_PORT = 6443;
9088
public static final int CLUSTER_NODES_DEFAULT_START_SSH_PORT = 2222;
9189

plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node-add.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
---
2020
users:
21-
- name: core
21+
- name: cloud
2222
sudo: ALL=(ALL) NOPASSWD:ALL
2323
shell: /bin/bash
2424
ssh_authorized_keys:
@@ -31,7 +31,7 @@ write_files:
3131
content: |
3232
#!/bin/bash -e
3333
34-
if [[ -f "/home/core/success" ]]; then
34+
if [[ -f "/home/cloud/success" ]]; then
3535
echo "Already provisioned!"
3636
exit 0
3737
fi
@@ -118,7 +118,7 @@ write_files:
118118
fi
119119
retval=0
120120
set +e
121-
docker load < "${BINARIES_DIR}/docker/$line"
121+
ctr image import "${BINARIES_DIR}/docker/$line"
122122
retval=$?
123123
set -e
124124
if [ $retval -eq 0 ]; then
@@ -165,7 +165,7 @@ write_files:
165165
fi
166166
167167
systemctl enable kubelet && systemctl start kubelet
168-
modprobe br_netfilter && sysctl net.bridge.bridge-nf-call-iptables=1
168+
modprobe overlay && modprobe br_netfilter && sysctl net.bridge.bridge-nf-call-iptables=1
169169
170170
if [ -d "$BINARIES_DIR" ] && [ "$ATTEMPT_ONLINE_INSTALL" = true ]; then
171171
crucial_cmd_attempts=1
@@ -176,7 +176,7 @@ write_files:
176176
fi
177177
retval=0
178178
set +e
179-
kubeadm config images pull
179+
kubeadm config images pull --cri-socket /run/containerd/containerd.sock
180180
retval=$?
181181
set -e
182182
if [ $retval -eq 0 ]; then
@@ -192,7 +192,7 @@ write_files:
192192
content: |
193193
#!/bin/bash -e
194194
195-
if [[ -f "/home/core/success" ]]; then
195+
if [[ -f "/home/cloud/success" ]]; then
196196
echo "Already provisioned!"
197197
exit 0
198198
fi
@@ -210,16 +210,16 @@ write_files:
210210
fi
211211
kubeadm join {{ k8s_control_node.join_ip }}:6443 --token {{ k8s_control_node.cluster.token }} --control-plane --certificate-key {{ k8s_control_node.cluster.ha.certificate.key }} --discovery-token-unsafe-skip-ca-verification
212212
213-
sudo touch /home/core/success
214-
echo "true" > /home/core/success
213+
sudo touch /home/cloud/success
214+
echo "true" > /home/cloud/success
215215
216216
- path: /etc/systemd/system/setup-kube-system.service
217217
permissions: '0755'
218218
owner: root:root
219219
content: |
220220
[Unit]
221-
Requires=docker.service
222-
After=docker.service
221+
Requires=containerd.service
222+
After=containerd.service
223223
224224
[Service]
225225
Type=simple
@@ -241,6 +241,7 @@ write_files:
241241
ExecStart=/opt/bin/deploy-kube-system
242242
243243
runcmd:
244+
- chown -R cloud:cloud /home/cloud/.ssh
244245
- [ systemctl, start, setup-kube-system ]
245246
- [ systemctl, start, deploy-kube-system ]
246247

0 commit comments

Comments
 (0)