https://pulumi.com logo
Title
p

proud-spoon-58287

11/09/2020, 11:18 AM
I want london region
I can create a new AWS provider
but I do not get how to link it to the eks creation part
const awsProvider = new aws.Provider("<http://stage.property.xyz|stage.property.xyz>",{
    region: "eu-west-2",
    maxRetries: 1,
    profile: "<http://stage.property.xyz|stage.property.xyz>"
})


// Create an EKS cluster with the default configuration.
const cluster = new eks.Cluster("my-cluster",{
});

// Export the cluster's kubeconfig.
export const kubeconfig = cluster.kubeconfig;
ok sorted
const awsProvider = new aws.Provider("aws-stage", {
    region: "eu-west-2",
    maxRetries: 1,
    profile: "<http://stage.property.xyz|stage.property.xyz>"
})
// Create an EKS cluster with non-default configuration
const vpc = new awsx.ec2.Vpc("vpc", {subnets: [{type: "public"}]});
const cluster = new eks.Cluster(name, {
        vpcId: vpc.id,
        subnetIds: vpc.publicSubnetIds,
        desiredCapacity: 2,
        minSize: 1,
        maxSize: 2,
        storageClasses: "gp2",
        deployDashboard: false,
        providerCredentialOpts: {
            profileName: "<http://stage.property.xyz|stage.property.xyz>"
        }
    },
    {
        provider: awsProvider
    });
returns this
error: Running program '/Users/sdicola/IdeaProjects/property-xyz/eks-pulumi' failed with an unhandled exception:
    Error: invocation of aws:index/getAvailabilityZones:getAvailabilityZones returned an error: 1 error occurred:
        * missing required configuration key "aws:region": The region where AWS operations will take place. Examples are us-east-1, us-west-2, etc.
    Set a value using the command `pulumi config set aws:region <value>`.
region is set in the provider....
don't get it
s

sticky-translator-17495

11/09/2020, 1:51 PM
You're not passing the
awsProvider
to the
awsx.ec2.Vpc
resource. That would make pulumi fallback on default provider configuration in your config file (I think), where you might be lacking the region?
p

proud-spoon-58287

11/09/2020, 2:53 PM
yep!
@sticky-translator-17495 I got an existing CRD. How can I use pulumi to deploy it?
guess the answer it this
s

sticky-translator-17495

11/09/2020, 3:15 PM
Yep, should work. Also, if you want to load it dynamically from some other source the k8s.yaml.ConfigFile could be helpful.
p

proud-spoon-58287

11/09/2020, 3:43 PM
ta
@sticky-translator-17495
const strimziNameSpace = new k8s.core.v1.Namespace("strimzi", undefined, {provider: strimziKafkaCluster.provider});

const strimziClusterOperator = new helm.v2.Chart("strimzi-kafka-operator", {
        fetchOpts: {
            repo: "<https://strimzi.io/charts/>"
        },
        chart: "strimzi-kafka-operator",
        version: "0.20.0",
        namespace: strimziNameSpace.metadata.name
    },
    {
        provider: strimziKafkaCluster.provider,
    }
);
why is it not creating the namespace?
s

sticky-translator-17495

11/10/2020, 12:24 PM
Looks fine. Do you get an error on the helm chart that the namespace doesn't exist? Maybe you need a
dependsOn: [strimziNameSpace]
on the helm chart?
p

proud-spoon-58287

11/10/2020, 12:25 PM
error: update failed
 
  kubernetes:<http://rbac.authorization.k8s.io/v1:RoleBinding|rbac.authorization.k8s.io/v1:RoleBinding> (strimzi-u4ii175e/strimzi-cluster-operator-topic-operator-delegation):
    error: resource strimzi-u4ii175e/strimzi-cluster-operator-topic-operator-delegation was not successfully created by the Kubernetes API server : namespaces "strimzi-u4ii175e" not found
{
        provider: awsProvider,
        dependsOn: strimziNameSpace
    }
?
got an error there
wants a resource :
sorry
wrong place 🙂
let me try
const awsProvider = new aws.Provider("aws-stage-provider", {
    region: "eu-west-2",
    profile: "<http://stage.property.xyz|stage.property.xyz>",
    maxRetries: 1
});

const kafkaVPC = new awsx.ec2.Vpc("strimzi-kafka-vpc", {
        subnets: [{type: "public"}]
    },
    {
        provider: awsProvider
    }
);

const strimziKafkaCluster = new eks.Cluster("strimzi-kafka", {
        vpcId: kafkaVPC.id,
        subnetIds: kafkaVPC.publicSubnetIds,
        storageClasses: "gp2",
        version: "1.18",
        deployDashboard: false,
        providerCredentialOpts: {
            profileName: "<http://stage.property.xyz|stage.property.xyz>"
        },
        nodeGroupOptions: {
            instanceType: "t3.micro",
            spotPrice: "0.9",
            desiredCapacity: 3,
            minSize: 1,
            maxSize: 3
        }
    },
    {
        provider: awsProvider,
    }
);

const strimziNameSpace = new k8s.core.v1.Namespace("strimzi", undefined, {provider: strimziKafkaCluster.provider});

const strimziClusterOperator = new helm.v2.Chart("strimzi-kafka-operator", {
        fetchOpts: {
            repo: "<https://strimzi.io/charts/>"
        },
        chart: "strimzi-kafka-operator",
        version: "0.20.0",
        namespace: strimziNameSpace.metadata.name
    },
    {
        provider: strimziKafkaCluster.provider,
        dependsOn: strimziNameSpace
    }
);

export const kubeconfig = strimziKafkaCluster.kubeconfig;
this is the script now
kubernetes:<http://rbac.authorization.k8s.io/v1:RoleBinding|rbac.authorization.k8s.io/v1:RoleBinding> (strimzi-u4ii175e/strimzi-cluster-operator-entity-operator-delegation):
    error: resource strimzi-u4ii175e/strimzi-cluster-operator-entity-operator-delegation was not successfully created by the Kubernetes API server : namespaces "strimzi-u4ii175e" not found
have the same error?
am I missing something @sticky-translator-17495?
s

sticky-translator-17495

11/10/2020, 12:31 PM
I think the
awsProvider
should be set on all resources?
p

proud-spoon-58287

11/10/2020, 1:01 PM
let me try
thanks mate
same thing
+  kubernetes:apps/v1:Deployment strimzi-u4ii175e/strimzi-cluster-operator creating Retry #5; creation failed: namespaces "strimzi-u4ii175e" not found
mmm
think I got it
is tehre any way to tell pulumi to not add anything to the name I gave
in other words
strimzi-80rac5e7   Active   32s
I would like only to see strimzi
?
sorted
❯ k get pods 
NAME                                        READY   STATUS    RESTARTS   AGE
strimzi-cluster-operator-7bb9fd9f7b-86w8m   1/1     Running   0          56s
@sticky-translator-17495 thanks again!