2019-10-16 13:05:14 -07:00
|
|
|
---
|
2023-06-02 21:41:36 -07:00
|
|
|
title_tag: Create Kubernetes Worker Nodes | Crosswalk
|
2019-12-18 09:59:20 -08:00
|
|
|
meta_desc: This page provides a guide on how to create Kubernetes Worker Nodes
|
|
|
|
with Pulumi.
|
2023-05-15 15:25:28 -07:00
|
|
|
title: Worker node creation
|
|
|
|
h1: Creating Kubernetes worker nodes
|
2023-06-08 16:15:52 -07:00
|
|
|
meta_image: /images/docs/meta-images/docs-clouds-kubernetes-meta-image.png
|
2019-10-16 13:05:14 -07:00
|
|
|
menu:
|
2023-05-15 15:25:28 -07:00
|
|
|
clouds:
|
|
|
|
parent: kubernetes-guides
|
|
|
|
identifier: kubernetes-guides-worker-nodes
|
2019-11-16 12:40:48 -08:00
|
|
|
weight: 3
|
2023-05-15 15:25:28 -07:00
|
|
|
aliases:
|
|
|
|
- /docs/guides/crosswalk/kubernetes/worker-nodes/
|
2019-10-16 13:05:14 -07:00
|
|
|
---
|
|
|
|
|
2020-03-23 21:06:03 -07:00
|
|
|
{{< chooser cloud "aws,azure,gcp" / >}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-11-12 10:30:40 -08:00
|
|
|
The [worker nodes][k8s-concepts] are hosts that
|
|
|
|
run the apps and workloads of the cluster after the control plane has
|
2019-10-18 16:35:15 +02:00
|
|
|
scheduled its work. It also typically facilitates virtual networking using an
|
2019-10-16 13:05:14 -07:00
|
|
|
overlay or integrated network depending on setup.
|
|
|
|
|
2019-10-17 11:48:26 -07:00
|
|
|
See the [official Kubernetes docs][k8s-docs] for more details.
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud aws %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-16 13:05:14 -07:00
|
|
|
The full code for this stack is on [GitHub][gh-repo-stack].
|
|
|
|
|
2019-11-13 09:53:50 -08:00
|
|
|
[gh-repo-stack]: https://github.com/pulumi/kubernetes-guides/tree/master/aws/03-cluster-configuration
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
|
|
|
|
|
|
|
{{% choosable cloud azure %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
|
|
|
The full code for this stack is on [GitHub][gh-repo-stack].
|
|
|
|
|
2019-11-13 09:53:50 -08:00
|
|
|
[gh-repo-stack]: https://github.com/pulumi/kubernetes-guides/tree/master/azure/03-cluster-configuration
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
|
|
|
|
|
|
|
{{% choosable cloud gcp %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
|
|
|
The full code for this stack is on [GitHub][gh-repo-stack].
|
|
|
|
|
2019-11-13 09:53:50 -08:00
|
|
|
[gh-repo-stack]: https://github.com/pulumi/kubernetes-guides/tree/master/gcp/03-cluster-configuration
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-16 13:05:14 -07:00
|
|
|
|
|
|
|
## Overview
|
|
|
|
|
2019-11-12 10:30:40 -08:00
|
|
|
Given that apps and workloads will vary in number, and in the resources they
|
|
|
|
require, it's best practice to make differing pools of nodes for Pods to use.
|
2019-10-16 13:05:14 -07:00
|
|
|
|
2019-11-08 21:31:35 -08:00
|
|
|
Pools, also known as Node Groups, can vary by instance type, sizing, capacity,
|
|
|
|
scaling group, or other properties like the version of the [Kubelet][k8s-kubelet] to run.
|
2019-10-16 13:05:14 -07:00
|
|
|
|
|
|
|
How you segment and configure your node groups will vary by preferences and
|
2019-11-12 10:30:40 -08:00
|
|
|
requirements. Generally, there are at minimum a few classes of worker node
|
|
|
|
groups, for example: a standard pool of nodes that offers a base for
|
2019-10-31 18:02:58 -07:00
|
|
|
medium-sized use, and a performant pool of nodes with higher capacity and capability.
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud aws %}}
|
2019-10-16 13:05:14 -07:00
|
|
|
|
|
|
|
We'll configure and deploy:
|
|
|
|
|
2019-12-18 09:59:20 -08:00
|
|
|
* [Node Identity](#node-identity): For authentication and authorization of the worker nodes.
|
|
|
|
* [Node Group Networking](#node-group-networking): To provide a virtual network for the
|
|
|
|
nodes and the Pods it runs.
|
|
|
|
* [Node Sizing](#node-sizing): To size our node scaling groups
|
|
|
|
* [Pod Scheduling](#pod-scheduling): To schedule Pods on nodes using predicates.
|
|
|
|
* [Recommended Worker Settings](#recommended-worker-settings): To apply helpful features
|
|
|
|
and best-practices, such as version pinning, and resource tags.
|
2019-10-16 13:05:14 -07:00
|
|
|
|
2019-11-12 11:09:27 -08:00
|
|
|
## Node Identity
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-16 13:05:14 -07:00
|
|
|
When creating node groups, it is recommended to use separate identities between
|
|
|
|
node groups, as separation of roles creates many functions: it can be used to
|
2019-11-12 10:30:40 -08:00
|
|
|
limit the scope of damage if a given group is compromised, can regulate the number
|
2019-10-16 13:05:14 -07:00
|
|
|
of API requests originating from a certain group, and can also help scope
|
|
|
|
privileges to specific node types and related workloads.
|
|
|
|
|
|
|
|
We'll create [AWS instance profiles][aws-instance-profile] from the roles we
|
|
|
|
created in [AWS Identity][crosswalk-aws-identity], and used earlier when [configuring node identity](#worker-node-groups) in the cluster.
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
// Create a Standard node group of t2.medium workers with an IAM instance profile.
|
|
|
|
const ngStandard = new eks.NodeGroup(`${projectName}-ng-standard`, {
|
|
|
|
cluster: cluster,
|
|
|
|
instanceType: "t2.medium",
|
|
|
|
instanceProfile: new aws.iam.InstanceProfile("ng-standard", {role: stdNodegroupIamRoleName}),
|
|
|
|
...
|
|
|
|
}, {
|
|
|
|
providers: { kubernetes: cluster.provider},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create a 2xlarge node group of t3.2xlarge workers with an IAM instance profile.
|
|
|
|
const ng2xlarge = new eks.NodeGroup(`${projectName}-ng-2xlarge`, {
|
|
|
|
cluster: cluster,
|
|
|
|
instanceType: "t3.2xlarge",
|
|
|
|
instanceProfile: new aws.iam.InstanceProfile("ng-2xlarge", {role: perfNodegroupIamRoleName}),
|
|
|
|
...
|
|
|
|
}, {
|
|
|
|
providers: { kubernetes: cluster.provider},
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2019-10-17 11:48:26 -07:00
|
|
|
[aws-instance-profile]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html
|
2023-05-15 15:25:28 -07:00
|
|
|
[crosswalk-aws-identity]: /docs/clouds/kubernetes/guides/identity/
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
|
|
|
|
|
|
|
{{% choosable cloud azure %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
We'll configure and deploy:
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-12-18 09:59:20 -08:00
|
|
|
* [Node Pool Sizing](#node-pool-sizing): To properly size our nodes.
|
|
|
|
* [Pod Scheduling](#pod-scheduling): To schedule Pods on nodes using predicates.
|
|
|
|
* [Recommended Worker Settings](#recommended-worker-settings): To apply helpful features
|
|
|
|
and best-practices.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud gcp %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
We'll configure and deploy:
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-12-18 09:59:20 -08:00
|
|
|
* [Node Sizing](#node-sizing): To properly size our nodes.
|
|
|
|
* [Pod Scheduling](#pod-scheduling): To schedule Pods on nodes using predicates.
|
|
|
|
* [Recommended Worker Settings](#recommended-worker-settings): To apply helpful features
|
|
|
|
and best-practices.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud aws %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-11-12 11:09:27 -08:00
|
|
|
## Node Group Networking
|
2019-10-31 18:02:58 -07:00
|
|
|
|
2019-10-16 13:05:14 -07:00
|
|
|
Node groups in EKS can also have their node security group be configured to a
|
|
|
|
new or existing security group.
|
|
|
|
|
2019-11-12 10:30:40 -08:00
|
|
|
To [create a custom security group][crosswalk-sgs], update the cluster's ingress
|
2019-10-16 13:05:14 -07:00
|
|
|
rule to correctly configure the ingress and egress rules.
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
// Create a Standard node group of t2.medium workers with an IAM instance profile.
|
|
|
|
const ngStandard = new eks.NodeGroup(`${projectName}-ng-standard`, {
|
|
|
|
cluster: cluster,
|
|
|
|
instanceType: "t2.medium",
|
|
|
|
nodeAssociatePublicIpAddress: false,
|
|
|
|
nodeSecurityGroup: cluster.nodeSecurityGroup,
|
|
|
|
clusterIngressRule: cluster.eksClusterIngressRule,
|
|
|
|
...
|
|
|
|
}, {
|
|
|
|
providers: { kubernetes: cluster.provider},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create a 2xlarge node group of t3.2xlarge workers with an IAM instance profile.
|
|
|
|
const ng2xlarge = new eks.NodeGroup(`${projectName}-ng-2xlarge`, {
|
|
|
|
cluster: cluster,
|
|
|
|
instanceType: "t3.2xlarge",
|
|
|
|
nodeAssociatePublicIpAddress: false,
|
|
|
|
nodeSecurityGroup: cluster.nodeSecurityGroup,
|
|
|
|
clusterIngressRule: cluster.eksClusterIngressRule,
|
|
|
|
...
|
|
|
|
}, {
|
|
|
|
providers: { kubernetes: cluster.provider},
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2023-05-15 15:25:28 -07:00
|
|
|
[crosswalk-sgs]: /docs/clouds/aws/guides/vpc/#configuring-security-groups-for-a-vpc
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
|
|
|
|
|
|
|
{{% choosable cloud azure %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-11-12 11:09:27 -08:00
|
|
|
## Node Pool Networking
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
Network profiles can be configured in Azure to work within the virtual network
|
|
|
|
created, allowing you to specify the Kubernetes Service and Docker network properties.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
|
|
|
```typescript
|
2019-10-31 18:02:58 -07:00
|
|
|
import * as azure from "@pulumi/azure";
|
|
|
|
|
|
|
|
// Create the AKS cluster within the network created.
|
|
|
|
const cluster = new azure.containerservice.KubernetesCluster(`${name}`, {
|
|
|
|
resourceGroupName: config.resourceGroupName,
|
|
|
|
networkProfile: {
|
|
|
|
networkPlugin: "azure",
|
|
|
|
dnsServiceIp: "10.2.2.254",
|
|
|
|
serviceCidr: "10.2.2.0/24",
|
|
|
|
dockerBridgeCidr: "172.17.0.1/16",
|
|
|
|
},
|
|
|
|
...
|
|
|
|
}
|
2019-10-17 11:48:26 -07:00
|
|
|
```
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-11-12 11:09:27 -08:00
|
|
|
## Node Sizing
|
2019-10-16 13:05:14 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud aws %}}
|
2019-10-30 12:09:56 +01:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
In EKS, worker node groups are backed by auto scaling groups.
|
|
|
|
These groups provide automatic scaling and management of a logical
|
2019-10-16 13:05:14 -07:00
|
|
|
collection of hosts through health checks and policies, and are an effective
|
|
|
|
means of ensuring node groups are adequately provisioned as intended.
|
|
|
|
|
2019-11-12 10:30:40 -08:00
|
|
|
We can configure the scaling group to run a specific number of nodes.
|
2019-10-16 13:05:14 -07:00
|
|
|
|
2019-10-18 16:35:15 +02:00
|
|
|
Size the node groups accordingly to known or approximate usage and bursting
|
2019-10-16 13:05:14 -07:00
|
|
|
expectations.
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
// Create a Standard node group of t2.medium workers with an IAM instance profile.
|
|
|
|
const ngStandard = new eks.NodeGroup(`${projectName}-ng-standard`, {
|
|
|
|
cluster: cluster,
|
|
|
|
instanceType: "t2.medium",
|
|
|
|
desiredCapacity: 3,
|
|
|
|
minSize: 3,
|
|
|
|
maxSize: 10,
|
|
|
|
...
|
|
|
|
}, {
|
|
|
|
providers: { kubernetes: cluster.provider},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create a 2xlarge node group of t3.2xlarge workers with an IAM instance profile.
|
|
|
|
const ng2xlarge = new eks.NodeGroup(`${projectName}-ng-2xlarge`, {
|
|
|
|
cluster: cluster,
|
|
|
|
instanceType: "t3.2xlarge",
|
|
|
|
desiredCapacity: 5,
|
|
|
|
minSize: 5,
|
|
|
|
maxSize: 10,
|
|
|
|
...
|
|
|
|
}, {
|
|
|
|
providers: { kubernetes: cluster.provider},
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud azure %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
In AKS, worker node pools are backed by [VM Scale Sets][azure-scalesets].
|
2019-10-30 12:09:56 +01:00
|
|
|
These pools provide automatic scaling and management of a logical
|
|
|
|
collection of hosts through health checks and policies, and are an effective
|
2019-10-31 18:02:58 -07:00
|
|
|
means of ensuring node pools are adequately provisioned as intended.
|
2019-10-30 12:09:56 +01:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
We can configure the agent pool profile to run a specific quantity and type of nodes.
|
2019-10-30 12:09:56 +01:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
Size the node pools accordingly to known or approximate usage and bursting
|
2019-10-30 12:09:56 +01:00
|
|
|
expectations.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
|
|
|
```typescript
|
2019-10-30 12:09:56 +01:00
|
|
|
const cluster = new azure.containerservice.KubernetesCluster(`${name}`, {
|
|
|
|
agentPoolProfiles: [{
|
|
|
|
name: "performant",
|
|
|
|
count: 3,
|
|
|
|
vmSize: "Standard_DS4_v2",
|
|
|
|
osType: "Linux",
|
|
|
|
osDiskSizeGb: 30,
|
|
|
|
vnetSubnetId: config.subnetId,
|
|
|
|
}, {
|
|
|
|
name: "standard",
|
|
|
|
count: 2,
|
|
|
|
vmSize: "Standard_B2s",
|
|
|
|
osType: "Linux",
|
|
|
|
osDiskSizeGb: 30,
|
|
|
|
vnetSubnetId: config.subnetId,
|
|
|
|
}],
|
|
|
|
// ...
|
|
|
|
});
|
2019-10-17 11:48:26 -07:00
|
|
|
```
|
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
[azure-scalesets]: https://azure.microsoft.com/en-us/services/virtual-machine-scale-sets/
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
|
|
|
|
|
|
|
{{% choosable cloud gcp %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
In GKE, worker node pools provide automatic scaling and management of a logical
|
|
|
|
collection of hosts through health checks and policies, and are an effective
|
|
|
|
means of ensuring node pools are adequately provisioned as intended.
|
|
|
|
|
2019-11-08 21:31:35 -08:00
|
|
|
We can configure the node config to run a specific quantity of nodes, along with
|
2019-10-31 18:02:58 -07:00
|
|
|
the min and max capacity the pool should have.
|
|
|
|
|
|
|
|
Size the node pools accordingly to known or approximate usage and bursting
|
|
|
|
expectations.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
|
|
|
```typescript
|
2019-10-31 18:02:58 -07:00
|
|
|
const standardNodes = new gcp.container.NodePool("standard-nodes", {
|
|
|
|
cluster: cluster.name,
|
|
|
|
version: "1.14.7-gke.10",
|
2019-11-04 19:22:20 -08:00
|
|
|
autoscaling: {minNodeCount: 0, maxNodeCount: 3},
|
2019-11-04 11:20:21 -08:00
|
|
|
initialNodeCount: 2,
|
2019-10-31 18:02:58 -07:00
|
|
|
...
|
|
|
|
});
|
|
|
|
|
|
|
|
const performantNodes = new gcp.container.NodePool("performant-nodes", {
|
|
|
|
cluster: cluster.name,
|
|
|
|
version: "1.14.7-gke.10",
|
2019-11-04 19:22:20 -08:00
|
|
|
autoscaling: {minNodeCount: 0, maxNodeCount: 3},
|
2019-11-04 11:20:21 -08:00
|
|
|
initialNodeCount: 2,
|
2019-10-31 18:02:58 -07:00
|
|
|
...
|
|
|
|
});
|
2019-10-17 11:48:26 -07:00
|
|
|
```
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-16 13:05:14 -07:00
|
|
|
If necessary, consider installing the [Kubernetes Cluster
|
|
|
|
Autoscaler][k8s-cluster-autoscaler] to automatically adjust the size of the
|
2019-11-12 10:30:40 -08:00
|
|
|
cluster when there are either insufficient resources for Pods or if nodes are
|
2019-10-16 13:05:14 -07:00
|
|
|
underutilized. You'll need to set up the appropriate tags on the node groups for
|
|
|
|
the `cluster-autoscaler` to run properly. See the [Recommended Worker
|
|
|
|
Settings](#recommended-worker-settings) below to configure the tags of
|
|
|
|
a node group accordingly for the `cluster-autoscaler`.
|
|
|
|
|
2019-11-12 11:09:27 -08:00
|
|
|
## Pod Scheduling
|
2019-10-16 13:05:14 -07:00
|
|
|
|
|
|
|
We can logically organize node groups in Kubernetes to use with configurable scheduling
|
|
|
|
predicates on Pods. Node [Labels][k8s-labels] are used to identify nodes by attributes,
|
2019-11-08 21:31:35 -08:00
|
|
|
and [Taints][k8s-taints] ensure that only workloads with a matching set of
|
|
|
|
tolerations are allowed to run on the nodes.
|
2019-10-16 13:05:14 -07:00
|
|
|
|
|
|
|
Both configurations can be set in the `PodSpec` using a
|
|
|
|
[`nodeSelector`][k8s-node-selector] or [`tolerations`][k8s-taints]
|
|
|
|
respectively.
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud aws %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-16 13:05:14 -07:00
|
|
|
```typescript
|
|
|
|
// Create a Standard node group of t2.medium workers with an IAM instance profile.
|
|
|
|
const ngStandard = new eks.NodeGroup(`${projectName}-ng-standard`, {
|
|
|
|
cluster: cluster,
|
|
|
|
instanceType: "t2.medium",
|
|
|
|
labels: {"amiId": "ami-0ca5998dc2c88e64b"},
|
|
|
|
...
|
|
|
|
}, {
|
|
|
|
providers: { kubernetes: cluster.provider},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create a 2xlarge node group of t3.2xlarge workers with an IAM instance profile.
|
|
|
|
const ng2xlarge = new eks.NodeGroup(`${projectName}-ng-2xlarge`, {
|
|
|
|
cluster: cluster,
|
|
|
|
instanceType: "t3.2xlarge",
|
|
|
|
labels: {"amiId": "ami-0ca5998dc2c88e64b"},
|
|
|
|
taints: { "special": { value: "true", effect: "NoSchedule"}},
|
|
|
|
...
|
|
|
|
}, {
|
|
|
|
providers: { kubernetes: cluster.provider},
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud azure %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
Set labels on nodes.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
|
|
|
```typescript
|
2019-10-31 18:02:58 -07:00
|
|
|
$ kubectl label nodes <NODE_NAME> disktype=ssd
|
|
|
|
```
|
|
|
|
|
|
|
|
Set taints on nodes.
|
2019-12-18 09:59:20 -08:00
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
```typescript
|
|
|
|
$ kubectl taint nodes <NODE_NAME> special=true:NoSchedule
|
2019-10-17 11:48:26 -07:00
|
|
|
```
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud gcp %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
|
|
|
```typescript
|
2019-10-31 18:02:58 -07:00
|
|
|
import * as gcp from "@pulumi/gcp";
|
|
|
|
|
|
|
|
const standardNodes = new gcp.container.NodePool("standard-nodes", {
|
|
|
|
cluster: cluster.name,
|
|
|
|
version: "1.14.7-gke.10",
|
2019-11-04 19:22:20 -08:00
|
|
|
autoscaling: {minNodeCount: 0, maxNodeCount: 3},
|
2019-11-04 11:20:21 -08:00
|
|
|
initialNodeCount: 2,
|
2019-10-31 18:02:58 -07:00
|
|
|
nodeConfig: {
|
|
|
|
machineType: "n1-standard-1",
|
|
|
|
oauthScopes: [
|
|
|
|
"https://www.googleapis.com/auth/compute",
|
|
|
|
"https://www.googleapis.com/auth/devstorage.read_only",
|
|
|
|
"https://www.googleapis.com/auth/logging.write",
|
|
|
|
"https://www.googleapis.com/auth/monitoring",
|
|
|
|
],
|
|
|
|
labels: {"instanceType": "n1-standard-1"},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const performantNodes = new gcp.container.NodePool("performant-nodes", {
|
|
|
|
cluster: cluster.name,
|
|
|
|
version: "1.14.7-gke.10",
|
2019-11-04 19:22:20 -08:00
|
|
|
autoscaling: {minNodeCount: 0, maxNodeCount: 3},
|
2019-11-04 11:20:21 -08:00
|
|
|
initialNodeCount: 2,
|
2019-10-31 18:02:58 -07:00
|
|
|
nodeConfig: {
|
|
|
|
machineType: "n1-standard-16",
|
|
|
|
oauthScopes: [
|
|
|
|
"https://www.googleapis.com/auth/compute",
|
|
|
|
"https://www.googleapis.com/auth/devstorage.read_only",
|
|
|
|
"https://www.googleapis.com/auth/logging.write",
|
|
|
|
"https://www.googleapis.com/auth/monitoring",
|
|
|
|
],
|
|
|
|
labels: {"instanceType": "n1-standard-16"},
|
|
|
|
taints: [{key: "special", value: "true", effect: "NO_SCHEDULE"}],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-10-17 11:48:26 -07:00
|
|
|
```
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-11-12 11:09:27 -08:00
|
|
|
## Recommended Worker Settings
|
2019-10-16 13:05:14 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud aws %}}
|
2019-10-31 18:02:58 -07:00
|
|
|
|
2019-12-18 09:59:20 -08:00
|
|
|
* Use a specific version of Kubernetes for each node group. This pins the nodes
|
|
|
|
to a particular release in a declarative manner, instead of implicitly
|
|
|
|
using the latest available version or using a smart default where both
|
|
|
|
can be updated at any moment.
|
|
|
|
* Tag resources under management to provide the ability to assign
|
|
|
|
metadata to resources to make it easier to manage, search, and filter them.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-16 13:05:14 -07:00
|
|
|
```typescript
|
2019-11-08 21:31:35 -08:00
|
|
|
// Create a Standard node group of t2.medium workers.
|
2019-10-16 13:05:14 -07:00
|
|
|
const ngStandard = new eks.NodeGroup(`${projectName}-ng-standard`, {
|
2019-11-08 21:31:35 -08:00
|
|
|
cluster: cluster,
|
|
|
|
amiId: "ami-0ca5998dc2c88e64b", // k8s v1.14.7 in us-west-2
|
|
|
|
instanceType: "t2.medium",
|
|
|
|
cloudFormationTags: clusterName.apply(clusterName => ({
|
|
|
|
"CloudFormationGroupTag": "true",
|
|
|
|
"k8s.io/cluster-autoscaler/enabled": "true",
|
|
|
|
[`k8s.io/cluster-autoscaler/${clusterName}`]: "true",
|
|
|
|
})),
|
|
|
|
...
|
2019-10-16 13:05:14 -07:00
|
|
|
}, {
|
2019-11-08 21:31:35 -08:00
|
|
|
providers: { kubernetes: cluster.provider},
|
2019-10-16 13:05:14 -07:00
|
|
|
});
|
|
|
|
|
2021-02-17 13:10:08 -08:00
|
|
|
// Create a 2xlarge node group of t3.2xlarge workers with labels for special workloads.
|
2019-10-16 13:05:14 -07:00
|
|
|
const ng2xlarge = new eks.NodeGroup(`${projectName}-ng-2xlarge`, {
|
2019-11-08 21:31:35 -08:00
|
|
|
cluster: cluster,
|
|
|
|
amiId: "ami-0ca5998dc2c88e64b", // k8s v1.14.7 in us-west-2
|
|
|
|
instanceType: "t3.2xlarge",
|
2021-02-17 13:10:08 -08:00
|
|
|
// Below are the labels your nodes will have that you can use a `nodeSelector`
|
|
|
|
// to target.
|
|
|
|
labels: { "workload": "special" },
|
|
|
|
// The Auto Scaling Group must also be labelled for the cluster autoscaler to
|
|
|
|
// work properly.
|
|
|
|
autoScalingGroupTags: {
|
|
|
|
"k8s.io/cluster-autoscaler/node-template/label/workload": "special"
|
|
|
|
},
|
2019-11-08 21:31:35 -08:00
|
|
|
cloudFormationTags: clusterName.apply(clusterName => ({
|
|
|
|
"CloudFormationGroupTag": "true",
|
|
|
|
"k8s.io/cluster-autoscaler/enabled": "true",
|
|
|
|
[`k8s.io/cluster-autoscaler/${clusterName}`]: "true",
|
|
|
|
})),
|
2019-10-16 13:05:14 -07:00
|
|
|
}, {
|
2019-11-08 21:31:35 -08:00
|
|
|
providers: { kubernetes: cluster.provider},
|
2019-10-16 13:05:14 -07:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud azure %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-12-18 09:59:20 -08:00
|
|
|
* Use a specific version of Kubernetes for each node group. This pins the nodes
|
|
|
|
to a particular release in a declarative manner, instead of implicitly
|
|
|
|
using the latest available version, or using a smart default where both
|
|
|
|
can be updated at any moment.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2020-03-20 09:32:19 -07:00
|
|
|
{{% choosable cloud gcp %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-12-18 09:59:20 -08:00
|
|
|
* Use a specific version of Kubernetes for each node group. This pins the nodes
|
2019-10-31 18:02:58 -07:00
|
|
|
to a particular release in a declarative manner, instead of implicitly
|
|
|
|
using the latest available version, or using a smart default where both
|
|
|
|
can be updated at any moment.
|
2019-12-18 09:59:20 -08:00
|
|
|
* Set [OAuth Scopes][gcp-oauth-scopes] for Google APIs to limit the capabilities of the node
|
2023-05-15 15:25:28 -07:00
|
|
|
pool, and enable managed Google Cloud logging and monitoring of the cluster.
|
2019-12-18 09:59:20 -08:00
|
|
|
* Tag resources under management to provide the ability to assign
|
2019-10-31 18:02:58 -07:00
|
|
|
metadata to resources to make it easier to manage, search, and filter them.
|
2019-10-17 11:48:26 -07:00
|
|
|
|
|
|
|
```typescript
|
2019-10-31 18:02:58 -07:00
|
|
|
import * as gcp from "@pulumi/gcp";
|
|
|
|
|
|
|
|
const standardNodes = new gcp.container.NodePool("standard-nodes", {
|
2019-11-04 11:20:21 -08:00
|
|
|
...
|
2019-10-31 18:02:58 -07:00
|
|
|
version: "1.14.7-gke.10",
|
|
|
|
nodeConfig: {
|
|
|
|
machineType: "n1-standard-1",
|
|
|
|
oauthScopes: [
|
|
|
|
"https://www.googleapis.com/auth/compute",
|
|
|
|
"https://www.googleapis.com/auth/devstorage.read_only",
|
|
|
|
"https://www.googleapis.com/auth/logging.write",
|
|
|
|
"https://www.googleapis.com/auth/monitoring",
|
|
|
|
],
|
|
|
|
tags: ["org-pulumi"],
|
|
|
|
},
|
|
|
|
});
|
2019-10-17 11:48:26 -07:00
|
|
|
```
|
|
|
|
|
2019-10-31 18:02:58 -07:00
|
|
|
[gcp-oauth-scopes]: https://developers.google.com/identity/protocols/googlescopes
|
|
|
|
[k8s-labels]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
|
2020-03-20 09:32:19 -07:00
|
|
|
|
|
|
|
{{% /choosable %}}
|
2019-10-17 11:48:26 -07:00
|
|
|
|
2019-10-16 13:05:14 -07:00
|
|
|
[k8s-concepts]: https://kubernetes.io/docs/concepts
|
|
|
|
[k8s-kubelet]: https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
|
|
|
|
[k8s-labels]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
|
|
|
|
[k8s-taints]: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
|
|
|
|
[k8s-cluster-autoscaler]: https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler
|
|
|
|
[k8s-node-selector]: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
|
|
|
|
[k8s-docs]: https://kubernetes.io/docs/reference/
|