mirror of
https://github.com/outbackdingo/terraform-render-bootstrap.git
synced 2026-01-28 02:20:38 +00:00
Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b339254ed5 | ||
|
|
9ccedf7b1e | ||
|
|
9795894004 | ||
|
|
bf07c3edad | ||
|
|
41a16db127 | ||
|
|
b83e321b35 | ||
|
|
28333ec9da | ||
|
|
891e88a70b | ||
|
|
5326239074 | ||
|
|
abe1f6dbf3 | ||
|
|
4260d9ae87 | ||
|
|
84c86ed81a | ||
|
|
a97f2ea8de | ||
|
|
5072569bb7 | ||
|
|
7a52b30713 | ||
|
|
73fcee2471 | ||
|
|
b25d802e3e | ||
|
|
df22b04db7 | ||
|
|
6dc7630020 | ||
|
|
3ec47194ce | ||
|
|
03ca146ef3 | ||
|
|
5763b447de | ||
|
|
36243ff89b | ||
|
|
810ddfad9f | ||
|
|
ec48758c5e | ||
|
|
533e82f833 | ||
|
|
31cfae5789 | ||
|
|
680244706c | ||
|
|
dbcf3b599f | ||
|
|
b7b56a6e55 | ||
|
|
a613c7dfa6 | ||
|
|
ab4d7becce | ||
|
|
4d85d9c0d1 | ||
|
|
ec5f86b014 | ||
|
|
92ff0f253a | ||
|
|
4f6af5b811 | ||
|
|
f76e58b56d | ||
|
|
383aba4e8e | ||
|
|
aebb45e6e9 | ||
|
|
b6b320ef6a | ||
|
|
9f4ffe273b | ||
|
|
74366f6076 | ||
|
|
db7c13f5ee | ||
|
|
3ac28c9210 | ||
|
|
64748203ba | ||
|
|
262cc49856 | ||
|
|
125f29d43d | ||
|
|
aded06a0a7 | ||
|
|
cc2b45780a | ||
|
|
d93b7e4dc8 | ||
|
|
48b33db1f1 | ||
|
|
8a9b6f1270 | ||
|
|
3b8d762081 | ||
|
|
9c144e6522 | ||
|
|
c0d4f56a4c | ||
|
|
62c887f41b | ||
|
|
dbfb11c6ea | ||
|
|
5ffbfec46d | ||
|
|
a52f99e8cc | ||
|
|
1c1c4b36f8 | ||
|
|
c4e87f9695 | ||
|
|
4cd0360a1a | ||
|
|
e7d2c1e597 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
||||
*.tfvars
|
||||
.terraform
|
||||
*.tfstate*
|
||||
assets
|
||||
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Dalton Hubble
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
44
README.md
44
README.md
@@ -1,62 +1,50 @@
|
||||
# bootkube-terraform
|
||||
# terraform-render-bootkube
|
||||
|
||||
`bootkube-terraform` is a Terraform module that renders [bootkube](https://github.com/kubernetes-incubator/bootkube) assets, just like running the binary `bootkube render`. It aims to provide the same variable names, defaults, features, and outputs.
|
||||
`terraform-render-bootkube` is a Terraform module that renders [kubernetes-incubator/bootkube](https://github.com/kubernetes-incubator/bootkube) assets for bootstrapping a Kubernetes cluster.
|
||||
|
||||
## Audience
|
||||
|
||||
`terraform-render-bootkube` is a low-level component of the [Typhoon](https://github.com/poseidon/typhoon) Kubernetes distribution. Use Typhoon modules to create and manage Kubernetes clusters across supported platforms. Use the bootkube module if you'd like to customize a Kubernetes control plane or build your own distribution.
|
||||
|
||||
## Usage
|
||||
|
||||
Use the `bootkube-terraform` module within your existing Terraform configs. Provide the variables listed in `variables.tf` or check `terraform.tfvars.example` for examples.
|
||||
Use the module to declare bootkube assets. Check [variables.tf](variables.tf) for options and [terraform.tfvars.example](terraform.tfvars.example) for examples.
|
||||
|
||||
```hcl
|
||||
module "bootkube" {
|
||||
source = "git://https://github.com/dghubble/bootkube-terraform.git?ref=SHA"
|
||||
source = "git://https://github.com/poseidon/terraform-render-bootkube.git?ref=SHA"
|
||||
|
||||
cluster_name = "example"
|
||||
api_servers = ["node1.example.com"]
|
||||
etcd_servers = ["node1.example.com"]
|
||||
asset_dir = "/home/core/clusters/mycluster"
|
||||
experimental_self_hosted_etcd = false
|
||||
}
|
||||
```
|
||||
|
||||
Alternately, use a local checkout of this repo and copy `terraform.tfvars.example` to `terraform.tfvars` to generate assets without an existing terraform config repo.
|
||||
|
||||
Generate the bootkube assets.
|
||||
Generate the assets.
|
||||
|
||||
```sh
|
||||
terraform get
|
||||
terraform init
|
||||
terraform get --update
|
||||
terraform plan
|
||||
terraform apply
|
||||
```
|
||||
|
||||
Find bootkube assets rendered to the `asset_dir` path. That's it.
|
||||
|
||||
### Comparison
|
||||
|
||||
Render bootkube assets directly with bootkube v0.5.1.
|
||||
|
||||
#### On-host etcd
|
||||
Render bootkube assets directly with bootkube v0.10.0.
|
||||
|
||||
```sh
|
||||
bootkube render --asset-dir=assets --api-servers=https://node1.example.com:443 --api-server-alt-names=DNS=node1.example.com --etcd-servers=https://node1.example.com:2379
|
||||
```
|
||||
|
||||
Compare assets. The only diffs you should see are TLS credentials.
|
||||
|
||||
```sh
|
||||
diff -rw assets /home/core/mycluster
|
||||
```
|
||||
|
||||
#### Self-hosted etcd
|
||||
|
||||
```sh
|
||||
bootkube render --asset-dir=assets --api-servers=https://node1.example.com:443 --api-server-alt-names=DNS=node1.example.com --experimental-self-hosted-etcd
|
||||
```
|
||||
|
||||
Compare assets. Note that experimental must be generated to a separate directory for terraform applies to sync. Move the experimental `bootstrap-manifests` and `manifests` files during deployment.
|
||||
Compare assets. Rendered assets may differ slightly from bootkube assets to reflect decisions made by the [Typhoon](https://github.com/poseidon/typhoon) distribution.
|
||||
|
||||
```sh
|
||||
pushd /home/core/mycluster
|
||||
mv experimental/bootstrap-manifests/* boostrap-manifests
|
||||
mv experimental/manifests/* manifests
|
||||
mv manifests-networking/* manifests
|
||||
popd
|
||||
diff -rw assets /home/core/mycluster
|
||||
```
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# Assets generated only when experimental self-hosted etcd is enabled
|
||||
|
||||
# bootstrap-etcd.yaml pod bootstrap-manifest
|
||||
resource "template_dir" "experimental-bootstrap-manifests" {
|
||||
count = "${var.experimental_self_hosted_etcd ? 1 : 0}"
|
||||
source_dir = "${path.module}/resources/experimental/bootstrap-manifests"
|
||||
destination_dir = "${var.asset_dir}/experimental/bootstrap-manifests"
|
||||
|
||||
vars {
|
||||
etcd_image = "${var.container_images["etcd"]}"
|
||||
bootstrap_etcd_service_ip = "${cidrhost(var.service_cidr, 20)}"
|
||||
}
|
||||
}
|
||||
|
||||
# etcd subfolder - bootstrap-etcd-service.json and migrate-etcd-cluster.json TPR
|
||||
resource "template_dir" "etcd-subfolder" {
|
||||
count = "${var.experimental_self_hosted_etcd ? 1 : 0}"
|
||||
source_dir = "${path.module}/resources/etcd"
|
||||
destination_dir = "${var.asset_dir}/etcd"
|
||||
|
||||
vars {
|
||||
bootstrap_etcd_service_ip = "${cidrhost(var.service_cidr, 20)}"
|
||||
}
|
||||
}
|
||||
|
||||
# etcd-operator deployment and etcd-service manifests
|
||||
# etcd client, server, and peer tls secrets
|
||||
resource "template_dir" "experimental-manifests" {
|
||||
count = "${var.experimental_self_hosted_etcd ? 1 : 0}"
|
||||
source_dir = "${path.module}/resources/experimental/manifests"
|
||||
destination_dir = "${var.asset_dir}/experimental/manifests"
|
||||
|
||||
vars {
|
||||
etcd_service_ip = "${cidrhost(var.service_cidr, 15)}"
|
||||
|
||||
# Self-hosted etcd TLS certs / keys
|
||||
etcd_ca_cert = "${base64encode(tls_self_signed_cert.etcd-ca.cert_pem)}"
|
||||
etcd_client_cert = "${base64encode(tls_locally_signed_cert.client.cert_pem)}"
|
||||
etcd_client_key = "${base64encode(tls_private_key.client.private_key_pem)}"
|
||||
etcd_server_cert = "${base64encode(tls_locally_signed_cert.server.cert_pem)}"
|
||||
etcd_server_key = "${base64encode(tls_private_key.server.private_key_pem)}"
|
||||
etcd_peer_cert = "${base64encode(tls_locally_signed_cert.peer.cert_pem)}"
|
||||
etcd_peer_key = "${base64encode(tls_private_key.peer.private_key_pem)}"
|
||||
}
|
||||
}
|
||||
26
assets.tf
26
assets.tf
@@ -5,7 +5,7 @@ resource "template_dir" "bootstrap-manifests" {
|
||||
|
||||
vars {
|
||||
hyperkube_image = "${var.container_images["hyperkube"]}"
|
||||
etcd_servers = "${var.experimental_self_hosted_etcd ? format("https://%s:2379,https://127.0.0.1:12379", cidrhost(var.service_cidr, 15)) : join(",", formatlist("https://%s:2379", var.etcd_servers))}"
|
||||
etcd_servers = "${join(",", formatlist("https://%s:2379", var.etcd_servers))}"
|
||||
|
||||
cloud_provider = "${var.cloud_provider}"
|
||||
pod_cidr = "${var.pod_cidr}"
|
||||
@@ -19,23 +19,30 @@ resource "template_dir" "manifests" {
|
||||
destination_dir = "${var.asset_dir}/manifests"
|
||||
|
||||
vars {
|
||||
hyperkube_image = "${var.container_images["hyperkube"]}"
|
||||
etcd_servers = "${var.experimental_self_hosted_etcd ? format("https://%s:2379", cidrhost(var.service_cidr, 15)) : join(",", formatlist("https://%s:2379", var.etcd_servers))}"
|
||||
hyperkube_image = "${var.container_images["hyperkube"]}"
|
||||
pod_checkpointer_image = "${var.container_images["pod_checkpointer"]}"
|
||||
kubedns_image = "${var.container_images["kubedns"]}"
|
||||
kubedns_dnsmasq_image = "${var.container_images["kubedns_dnsmasq"]}"
|
||||
kubedns_sidecar_image = "${var.container_images["kubedns_sidecar"]}"
|
||||
|
||||
cloud_provider = "${var.cloud_provider}"
|
||||
pod_cidr = "${var.pod_cidr}"
|
||||
service_cidr = "${var.service_cidr}"
|
||||
kube_dns_service_ip = "${cidrhost(var.service_cidr, 10)}"
|
||||
etcd_servers = "${join(",", formatlist("https://%s:2379", var.etcd_servers))}"
|
||||
|
||||
cloud_provider = "${var.cloud_provider}"
|
||||
pod_cidr = "${var.pod_cidr}"
|
||||
service_cidr = "${var.service_cidr}"
|
||||
cluster_domain_suffix = "${var.cluster_domain_suffix}"
|
||||
kube_dns_service_ip = "${cidrhost(var.service_cidr, 10)}"
|
||||
|
||||
ca_cert = "${base64encode(var.ca_certificate == "" ? join(" ", tls_self_signed_cert.kube-ca.*.cert_pem) : var.ca_certificate)}"
|
||||
server = "${format("https://%s:443", element(var.api_servers, 0))}"
|
||||
apiserver_key = "${base64encode(tls_private_key.apiserver.private_key_pem)}"
|
||||
apiserver_cert = "${base64encode(tls_locally_signed_cert.apiserver.cert_pem)}"
|
||||
serviceaccount_pub = "${base64encode(tls_private_key.service-account.public_key_pem)}"
|
||||
serviceaccount_key = "${base64encode(tls_private_key.service-account.private_key_pem)}"
|
||||
|
||||
etcd_ca_cert = "${base64encode(tls_self_signed_cert.etcd-ca.cert_pem)}"
|
||||
etcd_ca_cert = "${base64encode(tls_self_signed_cert.etcd-ca.cert_pem)}"
|
||||
etcd_client_cert = "${base64encode(tls_locally_signed_cert.client.cert_pem)}"
|
||||
etcd_client_key = "${base64encode(tls_private_key.client.private_key_pem)}"
|
||||
etcd_client_key = "${base64encode(tls_private_key.client.private_key_pem)}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +80,3 @@ data "template_file" "user-kubeconfig" {
|
||||
server = "${format("https://%s:443", element(var.api_servers, 0))}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
28
conditional.tf
Normal file
28
conditional.tf
Normal file
@@ -0,0 +1,28 @@
|
||||
# Assets generated only when certain options are chosen
|
||||
|
||||
resource "template_dir" "flannel-manifests" {
|
||||
count = "${var.networking == "flannel" ? 1 : 0}"
|
||||
source_dir = "${path.module}/resources/flannel"
|
||||
destination_dir = "${var.asset_dir}/manifests-networking"
|
||||
|
||||
vars {
|
||||
flannel_image = "${var.container_images["flannel"]}"
|
||||
flannel_cni_image = "${var.container_images["flannel_cni"]}"
|
||||
|
||||
pod_cidr = "${var.pod_cidr}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "template_dir" "calico-manifests" {
|
||||
count = "${var.networking == "calico" ? 1 : 0}"
|
||||
source_dir = "${path.module}/resources/calico"
|
||||
destination_dir = "${var.asset_dir}/manifests-networking"
|
||||
|
||||
vars {
|
||||
calico_image = "${var.container_images["calico"]}"
|
||||
calico_cni_image = "${var.container_images["calico_cni"]}"
|
||||
|
||||
network_mtu = "${var.network_mtu}"
|
||||
pod_cidr = "${var.pod_cidr}"
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,6 @@ output "kube_dns_service_ip" {
|
||||
value = "${cidrhost(var.service_cidr, 10)}"
|
||||
}
|
||||
|
||||
output "etcd_service_ip" {
|
||||
value = "${cidrhost(var.service_cidr, 15)}"
|
||||
}
|
||||
|
||||
output "kubeconfig" {
|
||||
value = "${data.template_file.kubeconfig.rendered}"
|
||||
}
|
||||
|
||||
@@ -8,11 +8,9 @@ spec:
|
||||
- name: kube-apiserver
|
||||
image: ${hyperkube_image}
|
||||
command:
|
||||
- /usr/bin/flock
|
||||
- /var/lock/api-server.lock
|
||||
- /hyperkube
|
||||
- apiserver
|
||||
- --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,ResourceQuota
|
||||
- --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,ValidatingAdmissionWebhook,ResourceQuota,DefaultTolerationSeconds,MutatingAdmissionWebhook
|
||||
- --advertise-address=$(POD_IP)
|
||||
- --allow-privileged=true
|
||||
- --authorization-mode=RBAC
|
||||
|
||||
@@ -12,6 +12,7 @@ spec:
|
||||
- controller-manager
|
||||
- --allocate-node-cidrs=true
|
||||
- --cluster-cidr=${pod_cidr}
|
||||
- --service-cluster-ip-range=${service_cidr}
|
||||
- --cloud-provider=${cloud_provider}
|
||||
- --configure-cloud-routes=false
|
||||
- --kubeconfig=/etc/kubernetes/kubeconfig
|
||||
|
||||
13
resources/calico/calico-bgp-peers.yaml
Normal file
13
resources/calico/calico-bgp-peers.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
description: Calico BGP Peers
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: bgppeers.crd.projectcalico.org
|
||||
spec:
|
||||
scope: Cluster
|
||||
group: crd.projectcalico.org
|
||||
version: v1
|
||||
names:
|
||||
kind: BGPPeer
|
||||
plural: bgppeers
|
||||
singular: bgppeer
|
||||
12
resources/calico/calico-cluster-role-binding.yaml
Normal file
12
resources/calico/calico-cluster-role-binding.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: calico-node
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: calico-node
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: calico-node
|
||||
namespace: kube-system
|
||||
53
resources/calico/calico-cluster-role.yaml
Normal file
53
resources/calico/calico-cluster-role.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: calico-node
|
||||
namespace: kube-system
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- namespaces
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- pods/status
|
||||
verbs:
|
||||
- update
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- pods
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- nodes
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- update
|
||||
- watch
|
||||
- apiGroups: ["extensions"]
|
||||
resources:
|
||||
- networkpolicies
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups: ["crd.projectcalico.org"]
|
||||
resources:
|
||||
- globalfelixconfigs
|
||||
- bgppeers
|
||||
- globalbgpconfigs
|
||||
- ippools
|
||||
- globalnetworkpolicies
|
||||
verbs:
|
||||
- create
|
||||
- get
|
||||
- list
|
||||
- update
|
||||
- watch
|
||||
39
resources/calico/calico-config.yaml
Normal file
39
resources/calico/calico-config.yaml
Normal file
@@ -0,0 +1,39 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: calico-config
|
||||
namespace: kube-system
|
||||
data:
|
||||
# The CNI network configuration to install on each node.
|
||||
cni_network_config: |-
|
||||
{
|
||||
"name": "k8s-pod-network",
|
||||
"cniVersion": "0.3.1",
|
||||
"plugins": [
|
||||
{
|
||||
"type": "calico",
|
||||
"log_level": "info",
|
||||
"datastore_type": "kubernetes",
|
||||
"nodename": "__KUBERNETES_NODE_NAME__",
|
||||
"mtu": ${network_mtu},
|
||||
"ipam": {
|
||||
"type": "host-local",
|
||||
"subnet": "usePodCidr"
|
||||
},
|
||||
"policy": {
|
||||
"type": "k8s",
|
||||
"k8s_auth_token": "__SERVICEACCOUNT_TOKEN__"
|
||||
},
|
||||
"kubernetes": {
|
||||
"k8s_api_root": "https://__KUBERNETES_SERVICE_HOST__:__KUBERNETES_SERVICE_PORT__",
|
||||
"kubeconfig": "__KUBECONFIG_FILEPATH__"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "portmap",
|
||||
"capabilities": {
|
||||
"portMappings": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
13
resources/calico/calico-gloabl-felix-configs.yaml
Normal file
13
resources/calico/calico-gloabl-felix-configs.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
description: Calico Global Felix Configuration
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: globalfelixconfigs.crd.projectcalico.org
|
||||
spec:
|
||||
scope: Cluster
|
||||
group: crd.projectcalico.org
|
||||
version: v1
|
||||
names:
|
||||
kind: GlobalFelixConfig
|
||||
plural: globalfelixconfigs
|
||||
singular: globalfelixconfig
|
||||
13
resources/calico/calico-global-bgp-configs.yaml
Normal file
13
resources/calico/calico-global-bgp-configs.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
description: Calico Global BGP Configuration
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: globalbgpconfigs.crd.projectcalico.org
|
||||
spec:
|
||||
scope: Cluster
|
||||
group: crd.projectcalico.org
|
||||
version: v1
|
||||
names:
|
||||
kind: GlobalBGPConfig
|
||||
plural: globalbgpconfigs
|
||||
singular: globalbgpconfig
|
||||
13
resources/calico/calico-ip-pools.yaml
Normal file
13
resources/calico/calico-ip-pools.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
description: Calico IP Pools
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: ippools.crd.projectcalico.org
|
||||
spec:
|
||||
scope: Cluster
|
||||
group: crd.projectcalico.org
|
||||
version: v1
|
||||
names:
|
||||
kind: IPPool
|
||||
plural: ippools
|
||||
singular: ippool
|
||||
13
resources/calico/calico-network-policies.yaml
Normal file
13
resources/calico/calico-network-policies.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
description: Calico Global Network Policies
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: globalnetworkpolicies.crd.projectcalico.org
|
||||
spec:
|
||||
scope: Cluster
|
||||
group: crd.projectcalico.org
|
||||
version: v1
|
||||
names:
|
||||
kind: GlobalNetworkPolicy
|
||||
plural: globalnetworkpolicies
|
||||
singular: globalnetworkpolicy
|
||||
5
resources/calico/calico-service-account.yaml
Normal file
5
resources/calico/calico-service-account.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: calico-node
|
||||
namespace: kube-system
|
||||
136
resources/calico/calico.yaml
Normal file
136
resources/calico/calico.yaml
Normal file
@@ -0,0 +1,136 @@
|
||||
apiVersion: apps/v1beta2
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: calico-node
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-app: calico-node
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: calico-node
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: calico-node
|
||||
spec:
|
||||
hostNetwork: true
|
||||
serviceAccountName: calico-node
|
||||
tolerations:
|
||||
# Allow the pod to run on master nodes
|
||||
- key: node-role.kubernetes.io/master
|
||||
effect: NoSchedule
|
||||
containers:
|
||||
- name: calico-node
|
||||
image: ${calico_image}
|
||||
env:
|
||||
# Use Kubernetes API as the backing datastore.
|
||||
- name: DATASTORE_TYPE
|
||||
value: "kubernetes"
|
||||
# Enable felix info logging.
|
||||
- name: FELIX_LOGSEVERITYSCREEN
|
||||
value: "info"
|
||||
# Cluster type to identify the deployment type
|
||||
- name: CLUSTER_TYPE
|
||||
value: "k8s,bgp"
|
||||
# Disable file logging so `kubectl logs` works.
|
||||
- name: CALICO_DISABLE_FILE_LOGGING
|
||||
value: "true"
|
||||
# Set Felix endpoint to host default action to ACCEPT.
|
||||
- name: FELIX_DEFAULTENDPOINTTOHOSTACTION
|
||||
value: "ACCEPT"
|
||||
# Disable IPV6 on Kubernetes.
|
||||
- name: FELIX_IPV6SUPPORT
|
||||
value: "false"
|
||||
# Set MTU for tunnel device used if ipip is enabled
|
||||
- name: FELIX_IPINIPMTU
|
||||
value: "${network_mtu}"
|
||||
# Wait for the datastore.
|
||||
- name: WAIT_FOR_DATASTORE
|
||||
value: "true"
|
||||
# The Calico IPv4 pool CIDR (should match `--cluster-cidr`).
|
||||
- name: CALICO_IPV4POOL_CIDR
|
||||
value: "${pod_cidr}"
|
||||
# Enable IPIP
|
||||
- name: CALICO_IPV4POOL_IPIP
|
||||
value: "Always"
|
||||
# Enable IP-in-IP within Felix.
|
||||
- name: FELIX_IPINIPENABLED
|
||||
value: "true"
|
||||
# Set node name based on k8s nodeName.
|
||||
- name: NODENAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
- name: IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.podIP
|
||||
- name: FELIX_HEALTHENABLED
|
||||
value: "true"
|
||||
securityContext:
|
||||
privileged: true
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /liveness
|
||||
port: 9099
|
||||
periodSeconds: 10
|
||||
initialDelaySeconds: 10
|
||||
failureThreshold: 6
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /readiness
|
||||
port: 9099
|
||||
periodSeconds: 10
|
||||
volumeMounts:
|
||||
- mountPath: /lib/modules
|
||||
name: lib-modules
|
||||
readOnly: true
|
||||
- mountPath: /var/run/calico
|
||||
name: var-run-calico
|
||||
readOnly: false
|
||||
# Install Calico CNI binaries and CNI network config file on nodes
|
||||
- name: install-cni
|
||||
image: ${calico_cni_image}
|
||||
command: ["/install-cni.sh"]
|
||||
env:
|
||||
- name: CNI_CONF_NAME
|
||||
value: 10-calico.conflist
|
||||
- name: CNI_NETWORK_CONFIG
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: calico-config
|
||||
key: cni_network_config
|
||||
- name: CNI_NET_DIR
|
||||
value: "/etc/kubernetes/cni/net.d"
|
||||
# Set node name based on k8s nodeName
|
||||
- name: KUBERNETES_NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
volumeMounts:
|
||||
- mountPath: /host/opt/cni/bin
|
||||
name: cni-bin-dir
|
||||
- mountPath: /host/etc/cni/net.d
|
||||
name: cni-net-dir
|
||||
terminationGracePeriodSeconds: 0
|
||||
volumes:
|
||||
- name: lib-modules
|
||||
hostPath:
|
||||
path: /lib/modules
|
||||
- name: var-run-calico
|
||||
hostPath:
|
||||
path: /var/run/calico
|
||||
- name: cni-bin-dir
|
||||
hostPath:
|
||||
path: /opt/cni/bin
|
||||
- name: cni-net-dir
|
||||
hostPath:
|
||||
path: /etc/kubernetes/cni/net.d
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Service",
|
||||
"metadata": {
|
||||
"name": "bootstrap-etcd-service",
|
||||
"namespace": "kube-system"
|
||||
},
|
||||
"spec": {
|
||||
"selector": {
|
||||
"k8s-app": "boot-etcd"
|
||||
},
|
||||
"clusterIP": "${bootstrap_etcd_service_ip}",
|
||||
"ports": [
|
||||
{
|
||||
"name": "client",
|
||||
"port": 12379,
|
||||
"protocol": "TCP"
|
||||
},
|
||||
{
|
||||
"name": "peers",
|
||||
"port": 12380,
|
||||
"protocol": "TCP"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"apiVersion": "etcd.coreos.com/v1beta1",
|
||||
"kind": "Cluster",
|
||||
"metadata": {
|
||||
"name": "kube-etcd",
|
||||
"namespace": "kube-system"
|
||||
},
|
||||
"spec": {
|
||||
"size": 1,
|
||||
"version": "v3.1.8",
|
||||
"pod": {
|
||||
"nodeSelector": {
|
||||
"node-role.kubernetes.io/master": ""
|
||||
},
|
||||
"tolerations": [
|
||||
{
|
||||
"key": "node-role.kubernetes.io/master",
|
||||
"operator": "Exists",
|
||||
"effect": "NoSchedule"
|
||||
}
|
||||
]
|
||||
},
|
||||
"selfHosted": {
|
||||
"bootMemberClientEndpoint": "https://${bootstrap_etcd_service_ip}:12379"
|
||||
},
|
||||
"TLS": {
|
||||
"static": {
|
||||
"member": {
|
||||
"peerSecret": "etcd-peer-tls",
|
||||
"serverSecret": "etcd-server-tls"
|
||||
},
|
||||
"operatorSecret": "etcd-client-tls"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: bootstrap-etcd
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-app: boot-etcd
|
||||
spec:
|
||||
containers:
|
||||
- name: etcd
|
||||
image: ${etcd_image}
|
||||
command:
|
||||
- /usr/local/bin/etcd
|
||||
- --name=boot-etcd
|
||||
- --listen-client-urls=https://0.0.0.0:12379
|
||||
- --listen-peer-urls=https://0.0.0.0:12380
|
||||
- --advertise-client-urls=https://${bootstrap_etcd_service_ip}:12379
|
||||
- --initial-advertise-peer-urls=https://${bootstrap_etcd_service_ip}:12380
|
||||
- --initial-cluster=boot-etcd=https://${bootstrap_etcd_service_ip}:12380
|
||||
- --initial-cluster-token=bootkube
|
||||
- --initial-cluster-state=new
|
||||
- --data-dir=/var/etcd/data
|
||||
- --peer-client-cert-auth=true
|
||||
- --peer-trusted-ca-file=/etc/kubernetes/secrets/etcd/peer-ca.crt
|
||||
- --peer-cert-file=/etc/kubernetes/secrets/etcd/peer.crt
|
||||
- --peer-key-file=/etc/kubernetes/secrets/etcd/peer.key
|
||||
- --client-cert-auth=true
|
||||
- --trusted-ca-file=/etc/kubernetes/secrets/etcd/server-ca.crt
|
||||
- --cert-file=/etc/kubernetes/secrets/etcd/server.crt
|
||||
- --key-file=/etc/kubernetes/secrets/etcd/server.key
|
||||
volumeMounts:
|
||||
- mountPath: /etc/kubernetes/secrets
|
||||
name: secrets
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: secrets
|
||||
hostPath:
|
||||
path: /etc/kubernetes/bootstrap-secrets
|
||||
hostNetwork: true
|
||||
restartPolicy: Never
|
||||
dnsPolicy: ClusterFirstWithHostNet
|
||||
@@ -1,10 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: etcd-client-tls
|
||||
namespace: kube-system
|
||||
type: Opaque
|
||||
data:
|
||||
etcd-client-ca.crt: ${etcd_ca_cert}
|
||||
etcd-client.crt: ${etcd_client_cert}
|
||||
etcd-client.key: ${etcd_client_key}
|
||||
@@ -1,43 +0,0 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: etcd-operator
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-app: etcd-operator
|
||||
spec:
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
maxSurge: 1
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: etcd-operator
|
||||
spec:
|
||||
containers:
|
||||
- name: etcd-operator
|
||||
image: quay.io/coreos/etcd-operator:v0.4.2
|
||||
command:
|
||||
- /usr/local/bin/etcd-operator
|
||||
- --analytics=false
|
||||
env:
|
||||
- name: MY_POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: MY_POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
nodeSelector:
|
||||
node-role.kubernetes.io/master: ""
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
@@ -1,10 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: etcd-peer-tls
|
||||
namespace: kube-system
|
||||
type: Opaque
|
||||
data:
|
||||
peer-ca.crt: ${etcd_ca_cert}
|
||||
peer.crt: ${etcd_peer_cert}
|
||||
peer.key: ${etcd_peer_key}
|
||||
@@ -1,10 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: etcd-server-tls
|
||||
namespace: kube-system
|
||||
type: Opaque
|
||||
data:
|
||||
server-ca.crt: ${etcd_ca_cert}
|
||||
server.crt: ${etcd_server_cert}
|
||||
server.key: ${etcd_server_key}
|
||||
@@ -1,18 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: etcd-service
|
||||
namespace: kube-system
|
||||
# This alpha annotation will retain the endpoints even if the etcd pod isn't ready.
|
||||
# This feature is always enabled in endpoint controller in k8s even it is alpha.
|
||||
annotations:
|
||||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
|
||||
spec:
|
||||
selector:
|
||||
app: etcd
|
||||
etcd_cluster: kube-etcd
|
||||
clusterIP: ${etcd_service_ip}
|
||||
ports:
|
||||
- name: client
|
||||
port: 2379
|
||||
protocol: TCP
|
||||
36
resources/flannel/kube-flannel-cfg.yaml
Normal file
36
resources/flannel/kube-flannel-cfg.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: kube-flannel-cfg
|
||||
namespace: kube-system
|
||||
labels:
|
||||
tier: node
|
||||
k8s-app: flannel
|
||||
data:
|
||||
cni-conf.json: |
|
||||
{
|
||||
"name": "cbr0",
|
||||
"cniVersion": "0.3.1",
|
||||
"plugins": [
|
||||
{
|
||||
"type": "flannel",
|
||||
"delegate": {
|
||||
"hairpinMode": true,
|
||||
"isDefaultGateway": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "portmap",
|
||||
"capabilities": {
|
||||
"portMappings": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
net-conf.json: |
|
||||
{
|
||||
"Network": "${pod_cidr}",
|
||||
"Backend": {
|
||||
"Type": "vxlan"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: kube-flannel
|
||||
@@ -7,6 +7,10 @@ metadata:
|
||||
tier: node
|
||||
k8s-app: flannel
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
tier: node
|
||||
k8s-app: flannel
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
@@ -15,7 +19,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: kube-flannel
|
||||
image: quay.io/coreos/flannel:v0.7.1-amd64
|
||||
image: ${flannel_image}
|
||||
command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr", "--iface=$(POD_IP)"]
|
||||
securityContext:
|
||||
privileged: true
|
||||
@@ -40,7 +44,7 @@ spec:
|
||||
- name: flannel-cfg
|
||||
mountPath: /etc/kube-flannel/
|
||||
- name: install-cni
|
||||
image: quay.io/coreos/flannel-cni:0.1.0
|
||||
image: ${flannel_cni_image}
|
||||
command: ["/install-cni.sh"]
|
||||
env:
|
||||
- name: CNI_NETWORK_CONFIG
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: "extensions/v1beta1"
|
||||
apiVersion: apps/v1beta2
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: kube-apiserver
|
||||
@@ -7,6 +7,10 @@ metadata:
|
||||
tier: control-plane
|
||||
k8s-app: kube-apiserver
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
tier: control-plane
|
||||
k8s-app: kube-apiserver
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
@@ -14,17 +18,14 @@ spec:
|
||||
k8s-app: kube-apiserver
|
||||
annotations:
|
||||
checkpointer.alpha.coreos.com/checkpoint: "true"
|
||||
scheduler.alpha.kubernetes.io/critical-pod: ''
|
||||
spec:
|
||||
containers:
|
||||
- name: kube-apiserver
|
||||
image: ${hyperkube_image}
|
||||
command:
|
||||
- /usr/bin/flock
|
||||
- /var/lock/api-server.lock
|
||||
- /hyperkube
|
||||
- apiserver
|
||||
- --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,ResourceQuota
|
||||
- --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,ValidatingAdmissionWebhook,ResourceQuota,DefaultTolerationSeconds,MutatingAdmissionWebhook
|
||||
- --advertise-address=$(POD_IP)
|
||||
- --allow-privileged=true
|
||||
- --anonymous-auth=false
|
||||
@@ -66,8 +67,6 @@ spec:
|
||||
nodeSelector:
|
||||
node-role.kubernetes.io/master: ""
|
||||
tolerations:
|
||||
- key: CriticalAddonsOnly
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
@@ -82,6 +81,6 @@ spec:
|
||||
hostPath:
|
||||
path: /var/lock
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: controller-manager
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: system:kube-controller-manager
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: kube-controller-manager
|
||||
namespace: kube-system
|
||||
5
resources/manifests/kube-controller-manager-sa.yaml
Normal file
5
resources/manifests/kube-controller-manager-sa.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
namespace: kube-system
|
||||
name: kube-controller-manager
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: kube-controller-manager
|
||||
@@ -8,13 +8,15 @@ metadata:
|
||||
k8s-app: kube-controller-manager
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
tier: control-plane
|
||||
k8s-app: kube-controller-manager
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
tier: control-plane
|
||||
k8s-app: kube-controller-manager
|
||||
annotations:
|
||||
scheduler.alpha.kubernetes.io/critical-pod: ''
|
||||
spec:
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
@@ -38,9 +40,11 @@ spec:
|
||||
command:
|
||||
- ./hyperkube
|
||||
- controller-manager
|
||||
- --use-service-account-credentials
|
||||
- --allocate-node-cidrs=true
|
||||
- --cloud-provider=${cloud_provider}
|
||||
- --cluster-cidr=${pod_cidr}
|
||||
- --service-cluster-ip-range=${service_cidr}
|
||||
- --configure-cloud-routes=false
|
||||
- --leader-elect=true
|
||||
- --root-ca-file=/etc/kubernetes/secrets/ca.crt
|
||||
@@ -63,9 +67,8 @@ spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
serviceAccountName: kube-controller-manager
|
||||
tolerations:
|
||||
- key: CriticalAddonsOnly
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: kube-dns
|
||||
@@ -6,6 +6,7 @@ metadata:
|
||||
labels:
|
||||
k8s-app: kube-dns
|
||||
kubernetes.io/cluster-service: "true"
|
||||
addonmanager.kubernetes.io/mode: Reconcile
|
||||
spec:
|
||||
# replicas: not specified here:
|
||||
# 1. In order to make Addon Manager do not reconcile this replicas parameter.
|
||||
@@ -22,12 +23,21 @@ spec:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kube-dns
|
||||
annotations:
|
||||
scheduler.alpha.kubernetes.io/critical-pod: ''
|
||||
spec:
|
||||
nodeSelector:
|
||||
node-role.kubernetes.io/master: ""
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
volumes:
|
||||
- name: kube-dns-config
|
||||
configMap:
|
||||
name: kube-dns
|
||||
optional: true
|
||||
containers:
|
||||
- name: kubedns
|
||||
image: gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.1
|
||||
image: ${kubedns_image}
|
||||
resources:
|
||||
# TODO: Set memory limits when we've profiled the container for large
|
||||
# clusters, then set request = limit to keep this container in
|
||||
@@ -57,7 +67,7 @@ spec:
|
||||
initialDelaySeconds: 3
|
||||
timeoutSeconds: 5
|
||||
args:
|
||||
- --domain=cluster.local.
|
||||
- --domain=${cluster_domain_suffix}.
|
||||
- --dns-port=10053
|
||||
- --config-dir=/kube-dns-config
|
||||
- --v=2
|
||||
@@ -78,7 +88,7 @@ spec:
|
||||
- name: kube-dns-config
|
||||
mountPath: /kube-dns-config
|
||||
- name: dnsmasq
|
||||
image: gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.1
|
||||
image: ${kubedns_dnsmasq_image}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthcheck/dnsmasq
|
||||
@@ -96,8 +106,9 @@ spec:
|
||||
- --
|
||||
- -k
|
||||
- --cache-size=1000
|
||||
- --no-negcache
|
||||
- --log-facility=-
|
||||
- --server=/cluster.local/127.0.0.1#10053
|
||||
- --server=/${cluster_domain_suffix}/127.0.0.1#10053
|
||||
- --server=/in-addr.arpa/127.0.0.1#10053
|
||||
- --server=/ip6.arpa/127.0.0.1#10053
|
||||
ports:
|
||||
@@ -116,7 +127,7 @@ spec:
|
||||
- name: kube-dns-config
|
||||
mountPath: /etc/k8s/dns/dnsmasq-nanny
|
||||
- name: sidecar
|
||||
image: gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.1
|
||||
image: ${kubedns_sidecar_image}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /metrics
|
||||
@@ -129,8 +140,8 @@ spec:
|
||||
args:
|
||||
- --v=2
|
||||
- --logtostderr
|
||||
- --probe=kubedns,127.0.0.1:10053,kubernetes.default.svc.cluster.local,5,A
|
||||
- --probe=dnsmasq,127.0.0.1:53,kubernetes.default.svc.cluster.local,5,A
|
||||
- --probe=kubedns,127.0.0.1:10053,kubernetes.default.svc.${cluster_domain_suffix},5,SRV
|
||||
- --probe=dnsmasq,127.0.0.1:53,kubernetes.default.svc.${cluster_domain_suffix},5,SRV
|
||||
ports:
|
||||
- containerPort: 10054
|
||||
name: metrics
|
||||
@@ -140,16 +151,4 @@ spec:
|
||||
memory: 20Mi
|
||||
cpu: 10m
|
||||
dnsPolicy: Default # Don't use cluster DNS.
|
||||
nodeSelector:
|
||||
node-role.kubernetes.io/master: ""
|
||||
tolerations:
|
||||
- key: CriticalAddonsOnly
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
volumes:
|
||||
- name: kube-dns-config
|
||||
configMap:
|
||||
name: kube-dns
|
||||
optional: true
|
||||
serviceAccountName: kube-dns
|
||||
|
||||
5
resources/manifests/kube-dns-sa.yaml
Normal file
5
resources/manifests/kube-dns-sa.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: kube-dns
|
||||
namespace: kube-system
|
||||
@@ -1,58 +0,0 @@
|
||||
apiVersion: "extensions/v1beta1"
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: kube-etcd-network-checkpointer
|
||||
namespace: kube-system
|
||||
labels:
|
||||
tier: control-plane
|
||||
k8s-app: kube-etcd-network-checkpointer
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
tier: control-plane
|
||||
k8s-app: kube-etcd-network-checkpointer
|
||||
annotations:
|
||||
checkpointer.alpha.coreos.com/checkpoint: "true"
|
||||
spec:
|
||||
containers:
|
||||
- image: quay.io/coreos/kenc:8f6e2e885f790030fbbb0496ea2a2d8830e58b8f
|
||||
name: kube-etcd-network-checkpointer
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- mountPath: /etc/kubernetes/selfhosted-etcd
|
||||
name: checkpoint-dir
|
||||
readOnly: false
|
||||
- mountPath: /var/etcd
|
||||
name: etcd-dir
|
||||
readOnly: false
|
||||
- mountPath: /var/lock
|
||||
name: var-lock
|
||||
readOnly: false
|
||||
command:
|
||||
- /usr/bin/flock
|
||||
- /var/lock/kenc.lock
|
||||
- -c
|
||||
- "kenc -r -m iptables && kenc -m iptables"
|
||||
hostNetwork: true
|
||||
nodeSelector:
|
||||
node-role.kubernetes.io/master: ""
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
volumes:
|
||||
- name: checkpoint-dir
|
||||
hostPath:
|
||||
path: /etc/kubernetes/checkpoint-iptables
|
||||
- name: etcd-dir
|
||||
hostPath:
|
||||
path: /var/etcd
|
||||
- name: var-lock
|
||||
hostPath:
|
||||
path: /var/lock
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
@@ -1,24 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: kube-flannel-cfg
|
||||
namespace: kube-system
|
||||
labels:
|
||||
tier: node
|
||||
k8s-app: flannel
|
||||
data:
|
||||
cni-conf.json: |
|
||||
{
|
||||
"name": "cbr0",
|
||||
"type": "flannel",
|
||||
"delegate": {
|
||||
"isDefaultGateway": true
|
||||
}
|
||||
}
|
||||
net-conf.json: |
|
||||
{
|
||||
"Network": "${pod_cidr}",
|
||||
"Backend": {
|
||||
"Type": "vxlan"
|
||||
}
|
||||
}
|
||||
12
resources/manifests/kube-proxy-role-binding.yaml
Normal file
12
resources/manifests/kube-proxy-role-binding.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: kube-proxy
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: system:node-proxier # Automatically created system role.
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: kube-proxy
|
||||
namespace: kube-system
|
||||
5
resources/manifests/kube-proxy-sa.yaml
Normal file
5
resources/manifests/kube-proxy-sa.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
namespace: kube-system
|
||||
name: kube-proxy
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: "extensions/v1beta1"
|
||||
apiVersion: apps/v1beta2
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: kube-proxy
|
||||
@@ -7,13 +7,15 @@ metadata:
|
||||
tier: node
|
||||
k8s-app: kube-proxy
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
tier: node
|
||||
k8s-app: kube-proxy
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
tier: node
|
||||
k8s-app: kube-proxy
|
||||
annotations:
|
||||
scheduler.alpha.kubernetes.io/critical-pod: ''
|
||||
spec:
|
||||
containers:
|
||||
- name: kube-proxy
|
||||
@@ -33,27 +35,32 @@ spec:
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- mountPath: /lib/modules
|
||||
name: lib-modules
|
||||
readOnly: true
|
||||
- mountPath: /etc/ssl/certs
|
||||
name: ssl-certs-host
|
||||
readOnly: true
|
||||
- name: etc-kubernetes
|
||||
- name: kubeconfig
|
||||
mountPath: /etc/kubernetes
|
||||
readOnly: true
|
||||
hostNetwork: true
|
||||
serviceAccountName: kube-proxy
|
||||
tolerations:
|
||||
- key: CriticalAddonsOnly
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /usr/share/ca-certificates
|
||||
name: ssl-certs-host
|
||||
- name: etc-kubernetes
|
||||
- name: lib-modules
|
||||
hostPath:
|
||||
path: /etc/kubernetes
|
||||
path: /lib/modules
|
||||
- name: ssl-certs-host
|
||||
hostPath:
|
||||
path: /usr/share/ca-certificates
|
||||
- name: kubeconfig
|
||||
configMap:
|
||||
name: kubeconfig-in-cluster
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
type: RollingUpdate
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: kube-scheduler
|
||||
@@ -8,13 +8,15 @@ metadata:
|
||||
k8s-app: kube-scheduler
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
tier: control-plane
|
||||
k8s-app: kube-scheduler
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
tier: control-plane
|
||||
k8s-app: kube-scheduler
|
||||
annotations:
|
||||
scheduler.alpha.kubernetes.io/critical-pod: ''
|
||||
spec:
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
@@ -51,8 +53,6 @@ spec:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
tolerations:
|
||||
- key: CriticalAddonsOnly
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1alpha1
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: system:default-sa
|
||||
|
||||
22
resources/manifests/kubeconfig-in-cluster.yaml
Normal file
22
resources/manifests/kubeconfig-in-cluster.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: kubeconfig-in-cluster
|
||||
namespace: kube-system
|
||||
data:
|
||||
kubeconfig: |
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- name: local
|
||||
cluster:
|
||||
server: ${server}
|
||||
certificate-authority: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||
users:
|
||||
- name: service-account
|
||||
user:
|
||||
# Use service account token
|
||||
tokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
contexts:
|
||||
- context:
|
||||
cluster: local
|
||||
user: service-account
|
||||
13
resources/manifests/pod-checkpointer-role-binding.yaml
Normal file
13
resources/manifests/pod-checkpointer-role-binding.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: pod-checkpointer
|
||||
namespace: kube-system
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: pod-checkpointer
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: pod-checkpointer
|
||||
namespace: kube-system
|
||||
12
resources/manifests/pod-checkpointer-role.yaml
Normal file
12
resources/manifests/pod-checkpointer-role.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: pod-checkpointer
|
||||
namespace: kube-system
|
||||
rules:
|
||||
- apiGroups: [""] # "" indicates the core API group
|
||||
resources: ["pods"]
|
||||
verbs: ["get", "watch", "list"]
|
||||
- apiGroups: [""] # "" indicates the core API group
|
||||
resources: ["secrets", "configmaps"]
|
||||
verbs: ["get"]
|
||||
5
resources/manifests/pod-checkpointer-sa.yaml
Normal file
5
resources/manifests/pod-checkpointer-sa.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
namespace: kube-system
|
||||
name: pod-checkpointer
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: "extensions/v1beta1"
|
||||
apiVersion: apps/v1beta2
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: pod-checkpointer
|
||||
@@ -7,6 +7,10 @@ metadata:
|
||||
tier: control-plane
|
||||
k8s-app: pod-checkpointer
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
tier: control-plane
|
||||
k8s-app: pod-checkpointer
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
@@ -17,11 +21,11 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: pod-checkpointer
|
||||
image: quay.io/coreos/pod-checkpointer:4e7a7dab10bc4d895b66c21656291c6e0b017248
|
||||
image: ${pod_checkpointer_image}
|
||||
command:
|
||||
- /checkpoint
|
||||
- --v=4
|
||||
- --lock-file=/var/run/lock/pod-checkpointer.lock
|
||||
- --kubeconfig=/etc/checkpointer/kubeconfig
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
@@ -37,10 +41,13 @@ spec:
|
||||
fieldPath: metadata.namespace
|
||||
imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- mountPath: /etc/checkpointer
|
||||
name: kubeconfig
|
||||
- mountPath: /etc/kubernetes
|
||||
name: etc-kubernetes
|
||||
- mountPath: /var/run
|
||||
name: var-run
|
||||
serviceAccountName: pod-checkpointer
|
||||
hostNetwork: true
|
||||
nodeSelector:
|
||||
node-role.kubernetes.io/master: ""
|
||||
@@ -50,6 +57,9 @@ spec:
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
volumes:
|
||||
- name: kubeconfig
|
||||
configMap:
|
||||
name: kubeconfig-in-cluster
|
||||
- name: etc-kubernetes
|
||||
hostPath:
|
||||
path: /etc/kubernetes
|
||||
@@ -57,6 +67,6 @@ spec:
|
||||
hostPath:
|
||||
path: /var/run
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
|
||||
@@ -2,4 +2,4 @@ cluster_name = "example"
|
||||
api_servers = ["node1.example.com"]
|
||||
etcd_servers = ["node1.example.com"]
|
||||
asset_dir = "/home/core/mycluster"
|
||||
experimental_self_hosted_etcd = false
|
||||
networking = "flannel"
|
||||
|
||||
31
tls-etcd.tf
31
tls-etcd.tf
@@ -96,17 +96,13 @@ resource "tls_cert_request" "client" {
|
||||
|
||||
ip_addresses = [
|
||||
"127.0.0.1",
|
||||
"${cidrhost(var.service_cidr, 15)}",
|
||||
"${cidrhost(var.service_cidr, 20)}",
|
||||
]
|
||||
|
||||
dns_names = "${concat(
|
||||
dns_names = ["${concat(
|
||||
var.etcd_servers,
|
||||
list(
|
||||
"localhost",
|
||||
"*.kube-etcd.kube-system.svc.cluster.local",
|
||||
"kube-etcd-client.kube-system.svc.cluster.local",
|
||||
))}"
|
||||
))}"]
|
||||
}
|
||||
|
||||
resource "tls_locally_signed_cert" "client" {
|
||||
@@ -139,20 +135,16 @@ resource "tls_cert_request" "server" {
|
||||
common_name = "etcd-server"
|
||||
organization = "etcd"
|
||||
}
|
||||
|
||||
|
||||
ip_addresses = [
|
||||
"127.0.0.1",
|
||||
"${cidrhost(var.service_cidr, 15)}",
|
||||
"${cidrhost(var.service_cidr, 20)}",
|
||||
]
|
||||
|
||||
dns_names = "${concat(
|
||||
dns_names = ["${concat(
|
||||
var.etcd_servers,
|
||||
list(
|
||||
"localhost",
|
||||
"*.kube-etcd.kube-system.svc.cluster.local",
|
||||
"kube-etcd-client.kube-system.svc.cluster.local",
|
||||
))}"
|
||||
))}"]
|
||||
}
|
||||
|
||||
resource "tls_locally_signed_cert" "server" {
|
||||
@@ -185,17 +177,8 @@ resource "tls_cert_request" "peer" {
|
||||
common_name = "etcd-peer"
|
||||
organization = "etcd"
|
||||
}
|
||||
|
||||
ip_addresses = [
|
||||
"${cidrhost(var.service_cidr, 20)}"
|
||||
]
|
||||
|
||||
dns_names = "${concat(
|
||||
var.etcd_servers,
|
||||
list(
|
||||
"*.kube-etcd.kube-system.svc.cluster.local",
|
||||
"kube-etcd-client.kube-system.svc.cluster.local",
|
||||
))}"
|
||||
|
||||
dns_names = ["${var.etcd_servers}"]
|
||||
}
|
||||
|
||||
resource "tls_locally_signed_cert" "peer" {
|
||||
|
||||
@@ -70,7 +70,7 @@ resource "tls_cert_request" "apiserver" {
|
||||
"kubernetes",
|
||||
"kubernetes.default",
|
||||
"kubernetes.default.svc",
|
||||
"kubernetes.default.svc.cluster.local",
|
||||
"kubernetes.default.svc.${var.cluster_domain_suffix}",
|
||||
]
|
||||
|
||||
ip_addresses = [
|
||||
|
||||
40
variables.tf
40
variables.tf
@@ -4,20 +4,15 @@ variable "cluster_name" {
|
||||
}
|
||||
|
||||
variable "api_servers" {
|
||||
description = "URL used to reach kube-apiserver"
|
||||
description = "List of URLs used to reach kube-apiserver"
|
||||
type = "list"
|
||||
}
|
||||
|
||||
variable "etcd_servers" {
|
||||
description = "List of etcd server URLs including protocol, host, and port. Ignored if experimental self-hosted etcd is enabled."
|
||||
description = "List of URLs used to reach etcd servers."
|
||||
type = "list"
|
||||
}
|
||||
|
||||
variable "experimental_self_hosted_etcd" {
|
||||
description = "(Experimental) Create self-hosted etcd assets"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "asset_dir" {
|
||||
description = "Path to a directory where generated assets should be placed (contains secrets)"
|
||||
type = "string"
|
||||
@@ -29,6 +24,18 @@ variable "cloud_provider" {
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "networking" {
|
||||
description = "Choice of networking provider (flannel or calico)"
|
||||
type = "string"
|
||||
default = "flannel"
|
||||
}
|
||||
|
||||
variable "network_mtu" {
|
||||
description = "CNI interface MTU (applies to calico only)"
|
||||
type = "string"
|
||||
default = "1500"
|
||||
}
|
||||
|
||||
variable "pod_cidr" {
|
||||
description = "CIDR IP range to assign Kubernetes pods"
|
||||
type = "string"
|
||||
@@ -38,20 +45,33 @@ variable "pod_cidr" {
|
||||
variable "service_cidr" {
|
||||
description = <<EOD
|
||||
CIDR IP range to assign Kubernetes services.
|
||||
The 1st IP will be reserved for kube_apiserver, the 10th IP will be reserved for kube-dns, the 15th IP will be reserved for self-hosted etcd, and the 20th IP will be reserved for bootstrap self-hosted etcd.
|
||||
The 1st IP will be reserved for kube_apiserver, the 10th IP will be reserved for kube-dns.
|
||||
EOD
|
||||
|
||||
type = "string"
|
||||
default = "10.3.0.0/24"
|
||||
}
|
||||
|
||||
variable "cluster_domain_suffix" {
|
||||
description = "Queries for domains with the suffix will be answered by kube-dns"
|
||||
type = "string"
|
||||
default = "cluster.local"
|
||||
}
|
||||
|
||||
variable "container_images" {
|
||||
description = "Container images to use"
|
||||
type = "map"
|
||||
|
||||
default = {
|
||||
hyperkube = "quay.io/coreos/hyperkube:v1.6.7_coreos.0"
|
||||
etcd = "quay.io/coreos/etcd:v3.1.8"
|
||||
calico = "quay.io/calico/node:v2.6.6"
|
||||
calico_cni = "quay.io/calico/cni:v1.11.2"
|
||||
flannel = "quay.io/coreos/flannel:v0.9.1-amd64"
|
||||
flannel_cni = "quay.io/coreos/flannel-cni:v0.3.0"
|
||||
hyperkube = "gcr.io/google_containers/hyperkube:v1.9.2"
|
||||
kubedns = "gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.8"
|
||||
kubedns_dnsmasq = "gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.8"
|
||||
kubedns_sidecar = "gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.8"
|
||||
pod_checkpointer = "quay.io/coreos/pod-checkpointer:08fa021813231323e121ecca7383cc64c4afe888"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user