Serverless Kubernetes
This resource will help you to manager a Serverless Kubernetes Cluster, see What is serverless kubernetes. The cluster is same as container service created by web console.
NOTE: Available since v1.58.0. NOTE: Serverless Kubernetes cluster only supports VPC network and it can access internet while creating kubernetes cluster. A Nat Gateway and configuring a SNAT for it can ensure one VPC network access internet. If there is no nat gateway in the VPC, you can set
new_nat_gateway
to "true" to create one automatically. NOTE: Creating serverless kubernetes cluster need to install several packages and it will cost about 5 minutes. Please be patient. NOTE: The provider supports to download kube config, client certificate, client key and cluster ca certificate after creating cluster successfully, and you can put them into the specified location, like '~/.kube/config'. NOTE: If you want to manage serverless Kubernetes, you can use Kubernetes Provider. NOTE: You need to activate several other products and confirm Authorization Policy used by Container Service before using this resource. Please refer to theAuthorization management
andCluster management
sections in the Document Center. NOTE: From version 1.162.0, support for creating professional serverless cluster.
Example Usage
Basic Usage
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.cs.ServerlessKubernetes;
import com.pulumi.alicloud.cs.ServerlessKubernetesArgs;
import com.pulumi.alicloud.cs.inputs.ServerlessKubernetesAddonArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var name = config.get("name").orElse("ask-example");
final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableResourceCreation("VSwitch")
.build());
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("10.1.0.0/21")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vswitchName(name)
.vpcId(defaultNetwork.id())
.cidrBlock("10.1.1.0/24")
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.build());
var serverless = new ServerlessKubernetes("serverless", ServerlessKubernetesArgs.builder()
.namePrefix(name)
.vpcId(defaultNetwork.id())
.vswitchIds(defaultSwitch.id())
.newNatGateway(true)
.endpointPublicAccessEnabled(true)
.deletionProtection(false)
.loadBalancerSpec("slb.s2.small")
.timeZone("Asia/Shanghai")
.serviceCidr("172.21.0.0/20")
.serviceDiscoveryTypes("PrivateZone")
.loggingType("SLS")
.tags(Map.ofEntries(
Map.entry("k-aa", "v-aa"),
Map.entry("k-bb", "v-aa")
))
.addons(
ServerlessKubernetesAddonArgs.builder()
.name("alb-ingress-controller")
.build(),
ServerlessKubernetesAddonArgs.builder()
.name("metrics-server")
.build(),
ServerlessKubernetesAddonArgs.builder()
.name("knative")
.build())
.build());
}
}
Import
Serverless Kubernetes cluster can be imported using the id, e.g. Then complete the main.tf accords to the result of pulumi preview
.
$ pulumi import alicloud:cs/serverlessKubernetes:ServerlessKubernetes main ce4273f9156874b46bb
Properties
Whether to enable cluster to support RRSA for version 1.22.3+. Default to false
. Once the RRSA function is turned on, it is not allowed to turn off. If your cluster has enabled this function, please manually modify your tf file and add the rrsa configuration to the file, learn more RAM Roles for Service Accounts.
The cluster api server load balance instance specification, default slb.s2.small
. For more information on how to select a LB instance specification, see SLB instance overview.