Skip to content

Commit

Permalink
Merge pull request #748 from polyseam/fix-nfs-bug
Browse files Browse the repository at this point in the history
[Bug]: Fix `*/microk8s` cloud-init errors related to nfs
  • Loading branch information
johnstonmatt authored Feb 28, 2024
2 parents 707369a + 7e0749c commit 8b52a09
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/cloud-init/microk8s/follower.yml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const getFollowerCloudInitYaml = (

// the following used to retry every 180 seconds until success:
loopUntilSuccess(
`while ! sudo snap install microk8s --classic --channel=${microk8sVersion}/${microk8sChannel}`,
`sudo snap install microk8s --classic --channel=${microk8sVersion}/${microk8sChannel}`,
`snap failed to install 'microk8s'`,
),

Expand Down
16 changes: 2 additions & 14 deletions src/cloud-init/microk8s/leader.yml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { CNDIConfig, Microk8sAddon } from "src/types.ts";
import getClusterRepoSecretSSHTemplate from "src/outputs/terraform/manifest-templates/argocd_private_repo_secret_ssh_manifest.yaml.tftpl.ts";
import getClusterRepoSecretHTTPSTemplate from "src/outputs/terraform/manifest-templates/argocd_private_repo_secret_https_manifest.yaml.tftpl.ts";
import getRootApplicationTemplate from "src/outputs/terraform/manifest-templates/argocd_root_application_manifest.yaml.tftpl.ts";
import getStorageClass from "src/outputs/terraform/manifest-templates/storage.yaml.tftpl.ts";

import { loopUntilSuccess } from "src/cloud-init/utils.ts";

Expand Down Expand Up @@ -133,9 +132,6 @@ const getLeaderCloudInitYaml = (
const PATH_TO_CLUSTER_REPO_SECRET_MANIFEST =
`${PATH_TO_MANIFESTS}/cluster-repo-secret.yaml`;

const PATH_TO_STORAGE_CLASS_MANIFEST =
`${PATH_TO_MANIFESTS}/storage-class.yaml`;

const PATH_TO_SEALED_SECRETS_PRIVATE_KEY =
`${WORKING_DIR}/sealed_secrets_private_key.key`;
const PATH_TO_SEALED_SECRETS_PUBLIC_KEY =
Expand All @@ -150,7 +146,7 @@ const getLeaderCloudInitYaml = (
// because this next line uses interpolation at runtime
// we install the nfs addon manually rather than declaritively
loopUntilSuccess(
'sudo microk8s enable nfs "$(hostname)"',
'sudo microk8s enable nfs -n "$(hostname)"',
"microk8s failed to enable 'nfs' addon",
),
`echo "nfs installed"`,
Expand All @@ -159,7 +155,7 @@ const getLeaderCloudInitYaml = (
let storageClassSetupCommands = [
`echo "Setting NFS as default storage class"`,
loopUntilSuccess(
`sudo microk8s kubectl apply -f ${PATH_TO_STORAGE_CLASS_MANIFEST}`,
`sudo microk8s kubectl patch storageclass nfs -p '{ "metadata": { "annotations": { "storageclass.kubernetes.io/is-default-class": "true" } } }'`,
`microk8s failed to install nfs`,
),
`echo "NFS is now the default storage class"`,
Expand All @@ -169,10 +165,6 @@ const getLeaderCloudInitYaml = (
packages = ["apache2-utils"]; // no nfs-common on dev clusters
storageClassSetupCommands = [
`echo "Setting hostpath-storage as default storage class"`,
loopUntilSuccess(
`sudo microk8s kubectl apply -f ${PATH_TO_STORAGE_CLASS_MANIFEST}`,
"microk8s failed to install hostpath-storage",
),
`echo "hostpath-storage is now the default storage class"`,
];
nfsInstallCommands = []; // no nfs on dev clusters, hostpath-storage is installed declaratively
Expand All @@ -184,10 +176,6 @@ const getLeaderCloudInitYaml = (
package_upgrade: false, // TODO: is package_upgrade:true better?
packages,
write_files: [
{
path: `${PATH_TO_MANIFESTS}/storage-class.yaml`,
content: getStorageClass(isDevCluster(config)),
},
{
path: PATH_TO_LAUNCH_CONFIG,
content: microk8sLeaderLaunchConfigYaml,
Expand Down
2 changes: 1 addition & 1 deletion src/outputs/terraform/aws/AWSEKSStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ export default class AWSEKSTerraformStack extends AWSCoreTerraformStack {
"node.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn",
value: webIdentityRole.arn,
},
{ name: "storageClasses[0].name", value: "rwm" },
{ name: "storageClasses[0].name", value: "nfs" },
{ name: "storageClasses[0].provisioner", value: "efs.csi.aws.com" },
{
name:
Expand Down
2 changes: 1 addition & 1 deletion src/outputs/terraform/azure/AzureAKSStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default class AzureAKSTerraformStack extends AzureCoreTerraformStack {
"cndi_kubernetes_storage_class_azure_file",
{
metadata: {
name: "rwm",
name: "nfs",
},
storageProvisioner: "file.csi.azure.com",
parameters: {
Expand Down
2 changes: 1 addition & 1 deletion src/outputs/terraform/gcp/GCPGKEStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ export default class GCPGKETerraformStack extends GCPCoreTerraformStack {
"cndi_kubernetes_storage_class_filestore",
{
metadata: {
name: "rwm",
name: "nfs",
},
parameters: {
network: network.name,
Expand Down
2 changes: 1 addition & 1 deletion templates/airflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ outputs:
persistence:
enabled: true
size: 15Gi
storageClassName: rwm
storageClassName: nfs
createUserJob:
useHelmHooks: false
migrateDatabaseJob:
Expand Down

0 comments on commit 8b52a09

Please sign in to comment.