GithubHelp home page GithubHelp logo

admission_controller_practice's Introduction

개요

kubernetes adminssion controller 연습

준비

  • kind 쿠버네티스 클러스터 생성
# 생성
make up

# 삭제
make down

실행 방법

self signed 인증서 생성

mkdir certs

openssl req -x509 -newkey rsa:4096 -nodes -out certs/ca.crt -keyout certs/ca.key -days 365 -config ./cert.cnf -extensions req_ext

kubectl create secret tls webhook-certs --cert=certs/ca.crt --key=certs/ca.key --namespace=default

admission controller를 실행할 golang pod 생성

  • golang 컨테이너가 있는 pod생성
kubectl apply -f ./manifests/golang-deployment.yaml
kubectl apply -f ./manifests/service.yaml
  • golang pod 쉘 접속
kubectl get pod -n default
kubectl exec -it {pod 이름} -- /bin/bash
  • go 모듈 초기화와 외부모듈 다운로드
go mod init github.com/opsarena/admission-controller
go get k8s.io/api/admission/v1
go get k8s.io/apimachinery/pkg/apis/meta/v1
go get k8s.io/api/core/v1
  • main.go 파일 생성: main.go파일을 pod안에 복사

  • main.go 실행

go run main.go

webhook 생성

  • validate webhook
CA_BUNDLE=$(cat ./certs/ca.crt | base64 | tr -d '\n')
sed -e 's@${CA_BUNDLE}@'"$CA_BUNDLE"'@g' < ./manifests/validation-webhook.yaml | kubectl apply -f -
  • mutate webhook
CA_BUNDLE=$(cat ./certs/ca.crt | base64 | tr -d '\n')
sed -e 's@${CA_BUNDLE}@'"$CA_BUNDLE"'@g' < ./manifests/mutate-webhook.yaml | kubectl apply -f -

admission controller 테스트

  • buysbox 생성 후 admission controller pod로그 확인
kubectl apply -f ./manifests/busybox-pod.yaml

참고자료

admission_controller_practice's People

Contributors

choisungwook avatar

Stargazers

Jinwoo Kim/DAX TF avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.