Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Securing Kubernetes Clusters on AWS (Japanese)

Securing Kubernetes Clusters on AWS (Japanese)

Kubernetes Meetup Tokyo #7
https://k8sjp.connpass.com/event/67092

KUOKA Yusuke

October 13, 2017
Tweet

More Decks by KUOKA Yusuke

Other Decks in Technology

Transcript

  1. ͓͞Β͍: ެ։͞ΕͨΞϓϦ͸Ͳ͏͍͏ܦ࿏ͰΞΫηε͞ΕΔ? -> LB (ELB, ALB, NLB) -> EC2Πϯελϯε (ServiceͷNodePortܦ༝)

    -> Pod (kube-proxy/iptables͕ServiceͷclusterIPΛpodIPʹม ׵) —> ίϯςφ (containerPortܦ༝) —> ΞϓϦέʔγϣϯϓϩηε ͱ͍͏ܦ࿏ͰΞΫηε͞ΕΔɻ
  2. ίϯςφʹೖ͍ͬͯΔ΋ͷ • ίϚϯυ • bash, curl, etc. • ϛυϧ΢ΣΞ •

    apache, nginx, etc. • ΞϓϦέʔγϣϯ • όΠφϦ(Golang)ɺεΫϦϓτ(ruby, python, etc.)
  3. ೚ҙͷίϚϯυΛ࣮ߦͰ͖Δͱ… • KubernetesͳΒͰ͸ͷ΋ͷ • K8S API, Kubelet API(ඇެ։), Podʹcurlͱ͔ͰΞΫηε •

    ίϯςφΦʔέετϨʔγϣϯγεςϜશൠʹ͋ͯ͸·Δ΋ ͷ • ଞͷίϯςφʹΞΫηε • localhost΍ϩʔΧϧϘϦϡʔϜܦ༝
  4. ۩ମతʹͲ͏ରࡦ͢Δ͔ • kube2iam • KubernetesͷNetwork Policies • RBAC • TLS

    Bootstrapping • ϊʔυϓʔϧɺΠϯελϯεϓʔϧ • coreos/clair
  5. όοΫυΞ࢓ࠐΊͳ͍Α͏ʹ͢Δ (2) CoreOSͷClairͰίϯςφΠϝʔδ੬ऑੑνΣοΫ ྫ: ੬ऑͳΠϝʔδ͕σϓϩΠ͞Εͳ͍Α͏ʹɺCIͰDocker Build & Pushͷޙʹ clair-scanner --clair

    https://myclaier.example.com --ip $YOUR_LOCAL_IP $IMAGE ͦͷ͋ͱK8SʹσϓϩΠ͢ΔΑ͏ʹ͢Δɻ ಉछͷπʔϧʹfuture-architect/vuls΋͋Γ·͢Ͷɻ
  6. Network Policies Podؒͷ௨৴ΛϧʔϧϕʔεͰڐՄɾېࢭ͢ΔͨΊͷ࢓૊Έ • PodΛෆཁͳΠϯλʔωοτ্ͷαʔϏεͱ௨৴ͤͨ͘͞ͳ ͍ • Pod΁ೖΔ: Ingress •

    Pod͔Βग़Δ: Egress (K8S 1.8͔Β࢖͑Δ) • EC2ϝλσʔλαʔϏε(169.254.169.254)͸σϑΥϧτϒ ϩοΫͰ͍͍ͷͰ͸
  7. TLS Bootstrapping • K8S API Server͕Kubelet΁ͷ௨৴ͷೝূɾ҉߸Խʹ࢖͏TLS ൿີ伴Λࣗಈੜ੒͢Δ • ྫ: kube-aws:

    伴͕શKubelet=WorkerͰڞ௨ɻ1 Workerͷ伴 ͕࿙ΕΔͱଞͷWorkerʹ΋Өڹ͕… • TLS BootstrappingΛ࢖͏ͱɺWorkerผͷ伴ʹͳΔɻ΋Εͯ ΋ͦͷWorker͚ͩʹӨڹ
  8. ରࡦ: K8SΫϥελʹGitHubϩάΠϯ Using guard, you can log into your Kubernetes

    cluster using your Github or Google authentication token https://github.com/appscode/guard • ͨͩ͠ɺGitHubͷOAuthτʔΫϯΛK8S APIτʔΫϯ͕ΘΓ ʹ࢖͏ • τʔΫϯͷ༗ޮظݶ͕௕͍ͱͦΕ͸ͦΕͰةͳ͍͔΋ • GoogleϩάΠϯ΋Ͱ͖Δ
  9. ରࡦ: K8SΫϥελʹAWS IAMͰϩάΠϯ kubernetes-aws-authenticator A tool for using AWS IAM

    credentials to authenticate to a Kubernetes cluster. https://github.com/heptiolabs/kubernetes-aws-authenticator • ͨͩ͠ɺAWSΫϨσϯγϟϧͷ༗ޮظݶ͕̍࣌ؒͳͷͰɺ࿙ ΕͨΒ̍࣌ؒ͸࢖ΘΕͯ͠·͏Մೳੑ • ωοτϫʔΫతͳରࡦ΋߹Θͤͯ
  10. TL;DR; K8S on AWSΛηΩϡΞʹ͍ͨ͠ͳΒɺ࠷௿ݶ • kube2iam • Network Policies •

    coreos/clair • RBAC Ͱ͖Ε͹ • ϊʔυϓʔϧɺTLS Bootstrapping