Project 2 Share
Project 2 Share
Machine2: Kmaster
Machine3: Kslave1
Machine4: Kslave2
Install terraform
provider "aws" {
secret_key = ""
access_key = ""
region = "us-west-1"
}
Terraform init
Terraform plan
Terraform apply
Go on Kmaster
Cd .ssh
Sudo nano authorized_keys
Paste ssh key
Go on Master:
Cd /etc/ansible
Ls
Sudo nano hosts
[test]
Private Ip of Kmaster
Ansible -m ping all
Playbook Syntax:
---
hosts: localhost
become: true
tasks:
script: Jenkins_terraform_ansible.sh
hosts: test
become: true
tasks:
script: K-master.sh
Jenkins_terraform_ansible.sh:
sudo apt update
Kmaster.sh
RUN PLAYBOOK :
ansible-playbook play.yaml
Dockerfile syntax
FROM ubuntu
kind: Deployment
metadata:
name: custom-deployment
labels:
app: custom
spec:
replicas: 2
selector:
matchLabels:
app: custom
template:
metadata:
labels:
app: custom
spec:
containers:
- name: custom
image: docker6767/image
ports:
- containerPort: 80
Create SVC.yml
apiVersion: v1
kind: Service
metadata:
name: my-custom-deployment
spec:
type: NodePort
ports:
- targetPort: 80
port: 80
nodePort: 30008
selector:
app: custom
Git status
Git add .
agent none
environment {
DOCKERHUB_CREDENTIALS=credentials('cba30343-cfdb-4b74-9ddd-518485437254
')
stages{
stage('Hello'){
agent{
label 'KMaster'
steps{
stage('git'){
agent{
label 'KMaster'
steps{
git'https://github.com/Intellipaat-Training/Test.git'
}
stage('docker') {
agent {
label 'KMaster'
steps {
stage('Kubernetes') {
agent {
label 'KMaster'
steps {