https://github.com/shavo007/k8s-ingress
showcase k8s cluster on aws using kops and ingress
https://github.com/shavo007/k8s-ingress
aws kubernetes kubernetes-deployment kubernetes-ingress-controller terraform
Last synced: 3 months ago
JSON representation
showcase k8s cluster on aws using kops and ingress
- Host: GitHub
- URL: https://github.com/shavo007/k8s-ingress
- Owner: shavo007
- Created: 2017-09-16T06:18:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-17T11:28:05.000Z (almost 8 years ago)
- Last Synced: 2025-04-10T01:08:25.418Z (6 months ago)
- Topics: aws, kubernetes, kubernetes-deployment, kubernetes-ingress-controller, terraform
- Language: Shell
- Size: 10.3 MB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# k8s-ingress
showcase k8s cluster on aws using kops and ingress
- - -## Installation
### Terraform
```bash
curl -LO https://releases.hashicorp.com/terraform/0.10.7/terraform_0.10.7_darwin_amd64.zip
unzip terraform_0.10.7_darwin_amd64.zip
sudo mv terraform /usr/local/bin/terraform
terraform
```### KOPS
```bash
echo "Download kops"curl -LO https://github.com/kubernetes/kops/releases/download/1.7.1/kops-darwin-amd64 && chmod +x kops-darwin-amd64 \
&& sudo mv kops-darwin-amd64 /usr/local/bin/kops \
&& echo "kops version installed is $(kops version)"
```## Creation of S3 bucket
```bash
terraform init -- Initialization (install the plugins for aws provider)
terraform plan -- Dry run
terraform apply -- Run
terraform show -- Inspect state```
## Create cluster
```bash
./deploy.sh
```### Export kube configuration
`kops export kubecfg ${NAME}`### dashboard
`kubectl proxy``open http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/`
## Ingress
### controller and back-end on aws* create ingress controller (nginx) on AWS and sample app echo-header
Follow instructions below:
https://github.com/kubernetes/ingress-nginx/tree/master/deploy
* Test accessing default back-end and echo-header service from ELB
ELB=$(kubectl get svc ingress-nginx -n ingress-nginx -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
```bash
curl $ELB
curl $ELB/backend -H 'Host: foo.bar.com'
```* Scale echo-headers deployment to three pods
`kubectl scale --replicas=3 deployment/echoheaders`* kubetail -- really useful tool to tail logs
```bash
brew tap johanhaleby/kubetail && brew install kubetail
```* Test sticky session (tail logs of pods and create ingress for sticky session)
```bash
kubetail -l app=echoheaderskubectl apply -f sticky-ingress.yaml
``````bash
curl -D cookies.txt $ELB/foo -H 'Host: stickyingress.example.com'while true; do sleep 1;curl -b cookies.txt $ELB/foo -H 'Host: stickyingress.example.com';done
```see that requests are directed to only one pod

* NGINX sample configuration
```bash
kubectl exec -it bash
cat /etc/nginx/nginx.confupstream sticky-default-echoheaders-x-80 {
sticky hash=sha1 name=route httponly;
server 100.96.2.8:8080 max_fails=0 fail_timeout=0;
server 100.96.1.5:8080 max_fails=0 fail_timeout=0;
server 100.96.2.7:8080 max_fails=0 fail_timeout=0;
}
```## Mobile app Cabin
Developed by guys at bitnami https://github.com/bitnami/cabinUseful for managing your cluster on the go!
## Resources
AWS Nginx ingress controller:
https://github.com/kubernetes/ingress/tree/master/controllers/nginxCreate cluster args: https://github.com/kubernetes/kops/blob/master/docs/cli/kops_create_cluster.md