Hey all, i am building out a new cluster (testing pulumi) and I am having issues setting the storage...
e
Hey all, i am building out a new cluster (testing pulumi) and I am having issues setting the storageclass to be
default
with gp2. It creates the storage class but does not make it default.... here is my eks settings
Copy code
import * as awsx from "@pulumi/awsx";
import * as eks from "@pulumi/eks";
import * as kubernetes from "@pulumi/kubernetes";

import { awsProvider } from "./providers";
import { awsProfile, desiredSize, eksClusterName, eksVersion, instanceType, minSize, maxSize, tags } from "./variables";

// Create a VPC for our cluster.
export const vpc = new awsx.ec2.Vpc(`${eksClusterName}-vpc`,
  {
    assignGeneratedIpv6CidrBlock: false,
    cidrBlock: "10.0.0.0/16",
    enableDnsHostnames: true,
    enableNetworkAddressUsageMetrics: true,
    tags: tags,
  },
  {
    provider: awsProvider,
  },
);

// Create an EKS cluster without node group configuration.
export const cluster = new eks.Cluster(`${eksClusterName}-cluster`,
  {
    enabledClusterLogTypes: [
      "api",
      "audit",
      "authenticator",
      "controllerManager",
      "scheduler",
    ],
    endpointPrivateAccess: true,
    endpointPublicAccess: true,
    name: eksClusterName,
    nodeRootVolumeEncrypted: true,
    nodeRootVolumeSize: 200,
    providerCredentialOpts: { profileName: awsProfile },
    subnetIds: vpc.publicSubnetIds,
    tags: tags,
    version: eksVersion,
    vpcId: vpc.vpcId,
  },
  {
    dependsOn: [vpc],
    provider: awsProvider,
  },
);

// Create an EKS managed node group.
new eks.ManagedNodeGroup(`${eksClusterName}-node-group`,
  {
    cluster: cluster,
    instanceTypes: [instanceType],
    nodeGroupName: `${eksClusterName}-nodegroup`,
    nodeRoleArn: cluster.instanceRoles[0].arn,
    diskSize: 200,
    tags: tags,

    scalingConfig: {
      desiredSize: desiredSize,
      maxSize: maxSize,
      minSize: minSize,
    },
  },
  {
    dependsOn: [cluster],
    provider: awsProvider,
  },
);
here is the sc it creates
Copy code
❯ kubectl get sc gp2 -o yaml

apiVersion: <http://storage.k8s.io/v1|storage.k8s.io/v1>
kind: StorageClass
metadata:
  annotations:
    <http://kubectl.kubernetes.io/last-applied-configuration|kubectl.kubernetes.io/last-applied-configuration>: |
      {"apiVersion":"<http://storage.k8s.io/v1|storage.k8s.io/v1>","kind":"StorageClass","metadata":{"annotations":{},"name":"gp2"},"parameters":{"fsType":"ext4","type":"gp2"},"provisioner":"<http://kubernetes.io/aws-ebs|kubernetes.io/aws-ebs>","volumeBindingMode":"WaitForFirstConsumer"}
  creationTimestamp: "2024-07-22T05:21:29Z"
  name: gp2
  resourceVersion: "276"
  uid: c6490311-0f24-4617-8912-ec8fab2e1e2e
parameters:
  fsType: ext4
  type: gp2
provisioner: <http://kubernetes.io/aws-ebs|kubernetes.io/aws-ebs>
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
How can i update it so it is
default
?
m
Where and how are you defining the storage class? (I don't see a Pulumi StorageClass resource in the code you shared.) To mark a storage class as "default," you need to annotate it, see this howto in the Kubernetes documentation. As far as I'm aware, Pulumi does not provide an abstraction for this. (Keep in mind that at most one storage class can be marked as "default", so if you already have a default storage class, you'll have to adjust its annotation accordingly.)
e
i wasn't defining a storageclass, but when i ran the kubectl get sc there was one so I assumed it was in the eks.cluster or managenodegroup
m
Per the docs, you can define this in two ways: • You can set
storage_classes="gp2"
on the
eks.Cluster
resource, which will make a default storage class with
gp2
(see https://github.com/pulumi/pulumi-eks/blob/12c643b3db4534be5c7b11c13603e5d8ce59a632/nodejs/eks/cluster.ts#L878) • You pass a map of storage classes and mark one of them as default According to the note in the documentation, you should also get a default
gp2
storage class automatically.