This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
[WIP] update suggestions for add features in aws mutlti zone support #1325
Open
cclhsu
wants to merge
3
commits into
SUSE:master
Choose a base branch
from
cclhsu:add_features_in_aws_mutlti_zone_support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,68 @@ | ||
data "template_file" "register_rmt" { | ||
template = file("cloud-init/register-rmt.tpl") | ||
count = var.rmt_server_name == "" ? 0 : 1 | ||
data "template_file" "repositories" { | ||
count = length(var.repositories) | ||
template = file("${path.module}/cloud-init/repository.tpl") | ||
|
||
vars = { | ||
rmt_server_name = var.rmt_server_name | ||
repository_url = element(values(var.repositories), count.index) | ||
repository_name = element(keys(var.repositories), count.index) | ||
} | ||
} | ||
|
||
data "template_file" "register_scc" { | ||
# register with SCC iff an RMT has not been provided | ||
count = var.caasp_registry_code != "" && var.rmt_server_name == "" ? 1 : 0 | ||
template = file("cloud-init/register-scc.tpl") | ||
template = file("${path.module}/cloud-init/register-scc.tpl") | ||
|
||
vars = { | ||
caasp_registry_code = var.caasp_registry_code | ||
} | ||
} | ||
|
||
data "template_file" "register_suma" { | ||
template = file("cloud-init/register-suma.tpl") | ||
count = var.suma_server_name == "" ? 0 : 1 | ||
data "template_file" "register_rmt" { | ||
count = var.rmt_server_name == "" ? 0 : 1 | ||
template = file("${path.module}/cloud-init/register-rmt.tpl") | ||
|
||
vars = { | ||
suma_server_name = var.suma_server_name | ||
rmt_server_name = var.rmt_server_name | ||
} | ||
} | ||
|
||
data "template_file" "repositories" { | ||
count = length(var.repositories) | ||
template = file("cloud-init/repository.tpl") | ||
data "template_file" "register_suma" { | ||
count = var.suma_server_name == "" ? 0 : 1 | ||
template = file("${path.module}/cloud-init/register-suma.tpl") | ||
|
||
vars = { | ||
repository_url = var.repositories[count.index] | ||
repository_name = var.repositories[count.index] | ||
suma_server_name = var.suma_server_name | ||
} | ||
} | ||
|
||
data "template_file" "commands" { | ||
template = file("cloud-init/commands.tpl") | ||
count = length(var.packages) == 0 ? 0 : 1 | ||
count = join("", var.packages) == "" ? 0 : 1 | ||
template = file("${path.module}/cloud-init/commands.tpl") | ||
|
||
vars = { | ||
packages = join(", ", var.packages) | ||
} | ||
} | ||
|
||
data "template_file" "cloud-init" { | ||
template = file("cloud-init/cloud-init.yaml.tpl") | ||
template = file("${path.module}/cloud-init/cloud-init.yaml.tpl") | ||
|
||
vars = { | ||
authorized_keys = join("\n", formatlist(" - %s", var.authorized_keys)) | ||
commands = join("\n", data.template_file.commands.*.rendered) | ||
repositories = length(var.repositories) == 0 ? "\n" : join("\n", data.template_file.repositories.*.rendered) | ||
register_scc = var.caasp_registry_code != "" && var.rmt_server_name == "" ? join("\n", data.template_file.register_scc.*.rendered) : "" | ||
register_rmt = var.rmt_server_name != "" ? join("\n", data.template_file.register_rmt.*.rendered) : "" | ||
register_suma = var.suma_server_name != "" ? join("\n", data.template_file.register_suma.*.rendered) : "" | ||
register_scc = join("\n", data.template_file.register_scc.*.rendered) | ||
register_rmt = join("\n", data.template_file.register_rmt.*.rendered) | ||
register_suma = join("\n", data.template_file.register_suma.*.rendered) | ||
repositories = join("\n", data.template_file.repositories.*.rendered) | ||
commands = join("\n", data.template_file.commands.*.rendered) | ||
} | ||
} | ||
|
||
data "template_cloudinit_config" "cfg" { | ||
gzip = false | ||
base64_encode = false | ||
base64_encode = true | ||
|
||
part { | ||
content_type = "text/cloud-config" | ||
content = data.template_file.cloud-init.rendered | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
#cloud-config | ||
# vim: syntax=yaml | ||
# | ||
# *********************** | ||
# ---- for more examples look at: ------ | ||
# ---> https://cloudinit.readthedocs.io/en/latest/topics/examples.html | ||
# ---> https://www.terraform.io/docs/providers/template/d/cloudinit_config.html | ||
# ****************************** | ||
# | ||
# This is the configuration syntax that the write_files module | ||
# will know how to understand. encoding can be given b64 or gzip or (gz+b64). | ||
# The content will be decoded accordingly and then written to the path that is | ||
# provided. | ||
# | ||
# Note: Content strings here are truncated for example purposes. | ||
|
||
# set locale | ||
locale: en_US.UTF-8 | ||
|
||
# set timezone | ||
timezone: Etc/UTC | ||
|
||
# Inject the public keys | ||
ssh_authorized_keys: | ||
${authorized_keys} | ||
|
||
# WARNING!!! Do not use cloud-init packages module when SUSE CaaSP Registration | ||
# Code is provided. In this case, repositories will be added in runcmd module | ||
# with SUSEConnect command after packages module is ran | ||
#packages: | ||
|
||
bootcmd: | ||
- ip link set dev eth0 mtu 1500 | ||
|
||
runcmd: | ||
${register_scc} | ||
${register_rmt} | ||
${register_suma} | ||
${repositories} | ||
${commands} | ||
|
||
final_message: "The system is finally up, after $UPTIME seconds" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
- echo "solver.onlyRequires = true" >> /etc/zypp/zypp.conf | ||
- [ zypper, -n, install, ${packages} ] | ||
- [ ip, link, delete, docker0 ] | ||
- ip link delete docker0 | ||
- iptables -L | grep DOCKER | awk {'print $2'} | xargs -d "\n" -i iptables -X {} | ||
- iptables-save | awk '/^[*]/ { print $1 "\nCOMMIT" }' | iptables-restore | ||
- lsmod | egrep ^iptable_ | awk '{print $1}' | xargs -rd\\n modprobe -r | ||
- echo "solver.onlyRequires = true" >> /etc/zypp/zypp.conf | ||
- zypper -n install ${packages} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
- curl --tlsv1.2 --silent --insecure --connect-timeout 10 https://${rmt_server_name}/rmt.crt --output /etc/pki/trust/anchors/rmt-server.pem && /usr/sbin/update-ca-certificates &> /dev/null | ||
- SUSEConnect --url https://${rmt_server_name} | ||
- SUSEConnect -p sle-module-containers/15.2/x86_64 | ||
- SUSEConnect -p caasp/4.5/x86_64 | ||
- SUSEConnect -p caasp/4.5/x86_64 -r ${caasp_registry_code} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
- id: ${repository_name} | ||
name: ${repository_name} | ||
baseurl: ${repository_url} | ||
enabled: 1 | ||
autorefresh: 1 | ||
gpgcheck: 0 | ||
- zypper --refresh ${repository_url} ${repository_name} | ||
- zypper --gpg-auto-import-keys refresh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html | ||
|
||
export AWS_ACCESS_KEY_ID="" | ||
export AWS_SECRET_ACCESS_KEY="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
locals { | ||
# Do not add the special `kubernetes.io/cluster<cluster-name>` here, | ||
# this tag cannot be added to all our resources otherwise the CPI | ||
# will get confused when dealing with security rules objects. | ||
basic_tags = merge( | ||
{ | ||
"Name" = var.stack_name | ||
"Environment" = var.stack_name | ||
}, | ||
var.tags, | ||
) | ||
|
||
# tags = local.basic_tags | ||
tags = merge( | ||
local.basic_tags, | ||
{ | ||
format("kubernetes.io/cluster/%v", var.stack_name) = "SUSE-terraform" | ||
}, | ||
) | ||
} | ||
|
||
# https://www.terraform.io/docs/providers/aws/index.html | ||
provider "aws" { | ||
profile = "default" | ||
region = var.aws_region | ||
} | ||
|
||
data "susepubliccloud_image_ids" "sles15sp2_chost_byos" { | ||
cloud = "amazon" | ||
region = var.aws_region | ||
state = "active" | ||
|
||
# USE SLES 15 SP2 Container host AMI - this is needed to avoid issues like bsc#1146774 | ||
name_regex = "suse-sles-15-sp2-chost-byos.*-hvm-ssd-x86_64" | ||
} | ||
|
||
resource "aws_key_pair" "kube" { | ||
key_name = "${var.stack_name}-keypair" | ||
public_key = element(var.authorized_keys, 0) | ||
|
||
tags = merge( | ||
local.basic_tags, | ||
{ | ||
"Name" = "${var.stack_name}-keypair" | ||
"Class" = "KeyPair" | ||
}, | ||
) | ||
} | ||
|
||
# list of availability_zones which can be access from the current region | ||
data "aws_availability_zones" "availability_zones" { | ||
state = "available" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dannysauer Correct me if i'm wrong but I don't think we should expose the API server too the web. this is an easy first step to securing them, making it so that only inside the cluster can directly hit the api server. I would be for removing this block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not completely clear why we open 80/443 to begin with; nothing listens on those ports by default, right? Was that just a copy-paste from an example that was left behind all along?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, yes, exposing the api server seems undesirable. I guess it's possible to control access to the whole vpc and that might be an acceptable control, but I honestly haven't read the entire config to see if that's being done. It still seems like it'd be preferable to elect a source IP as "management node" or identify a management network.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from original code. I just try to rearrange code by function. I will test to remove 80/443 to see if any side effect