-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfs.txt
364 lines (230 loc) · 6.81 KB
/
fs.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
JENKINS:
download java 17 archive
Jenkins download
java -jar Jenkins.war --httpPort=8081
(copy pasword)
http://localhost:8080
Create jenkins
create new repo
copypath
open notepad
class HelloWorld {
// Your program begins with a call to main().
// Prints "Hello, World" to the terminal window.
public static void main(String args[])
{
System.out.println("Hello, World");
}
}
save same a class HelloWorld.java
git clone https://github.com/GowsikaPerumal/demo.git
cd demo
git add HelloWorld.java
git commit -m "hello"
git config --global user.name"<yourname"> #TEJASWINIRAMESH
git config --global user.email"<yourmail">#[email protected]
git push origin main
JENKINS:
New item-> Free style-> select Git-> enter git repo-> Add a buid step-> select executewindow batch command-> javac HelloWorld.java-> java HelloWorld
Build Now
DOCKER
sudo apt update
sudo apt install docker.io
entr 'Y'
sudo systemctl start docker
sudo systemctl enable docker
mkdir flaskapp
cd flaskapp
app.py:
from flask import Flask
app=Flask(__name__)
@app.route('/')
def home():
return "Hello World"
if __name=="__main__":
app.run(host='0.0.0.0',Port=5000)
requirements.txt
Flask == 2.3.2
Dockerfile
From python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python","app.py"]
sudo docker build -t flaskapp .
sudo docker run -p 5000:5000 flaskapp
PUSH&PULL
sudo docker build -t <username>/flaskapp .
sudo docker run -p 5000:5000 <username>/flaskapp
docker push <username>/flaskapp
docker pull <username>/flaskapp
SSH
ssh-keygen -t rsa -b 2048
ssh-copy-id 3122215002011@otheruserip_add
ssh 3122215002011@otheruserip_add
nano ~/test_script.sh
echo "hello SSH"
for nano, press CTRL + X, then Y, and hit Enter)
now in other user pc
ssh theirusername@their_ip_addr 'bash ~/test_script.sh'
ssh-keygen -t rsa -b 2048
ssh-copy-id username@ip
ssh usrname@ip
nano script.sh
echo "hthg"
(ctr+o,enter,ctr+x)
chmod +x script.sh
./script.sh
ssh user@ip 'bash~/script.sh'
ssh-keygen -t rsa -b 2048
Enter
Enter
Enter
ssh-copy-id rem_username@rem_ip
( Will ask remote system password)
ssh rem_username@rem_ip
nano script.sh
echo "hello world"
Ctrl + O
Enter
Ctrl + X
Chmod +x script.sh
./script.sh
(If not exited from remote system, type exit )
ssh remusername@rem_ip 'bash ~/script.sh'
O/P is seen (hello world)
SSH USING JENKINS
Start jenkins server and login
Manage Jenkins > Manage Plugins
Available > search for Publish over SSH
Check the box near it and click download/install
Manage Jenkins > System
Scroll down down down to find publish over SSH
Click add
Fill in details
Name - summa
Hostname - rem_ip
Username - for ssh access on rem system
Passphrase/ssh key - paste private key from ~/.ssh/id_rsa ( use cat command and this path)
Click save
New item
Freestyle
Build section, add build step > send fules or execute over ssh
Select ssh config u just added
bash ~/script.sh
Save
Build now
Console output
Load Balancing
docker build -t new_flask
docker run -d --name app1 -p 5001:5000 new_flask
docker run -d --name app2 -p 5002:5000 new_flask
docker run -d --name app3 -p 5003:5000 new_flask
if error for port not found:
docker ps -a
docker stop container_id
docker rm container_id
sudo apt update
sudo apt install -y nginx
cd /etc/nginx/sites-available
sudo nano new_flask
upstream flask_app {
server 127.0.0.1:6001;
server 127.0.0.1:6002;
server 127.0.0.1:6003;
}
server {
listen 80;
location / {
proxy_pass http://flask_app;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
ctrl+x,Y,enter
sudo ln -s /etc/nginx/sites-available/new_flask/etc/nginx/sites-enabled/
sudo nginx -t
.
.
. test is successful
sudo systemctl restart nginx
sudo systemctl status nginx
Sometimes close aagadhu go to new terminal and do below
hostname -I
smtg 10.0.2.15
http://10.0.2.15/ -----> nginx page
http://10.0.2.15:5001
JENKINS DOWNLOAD IN UBUNTU
sudo apt-get update
sudo apt-get install jenkins
sudo apt install fontconfig openjdk-17-jre
java --version
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword --------> Gives the password
SSH FILE TRANSFER IN UBUNTU
LOCAL SYSTEM la
SENDING FILE TO REMOTE SYSTEM:
If file in Desktop(hello.sh):
scp
cd Desktop/
scp hello.sh remoteusername@remoteipaddress:/home/codebind (Where to save in the remote system)
yes
Remote password
FETCHING FILE FROM REMOTE
scp remoteusername@remoteipaddress:/home/codebind/file.txt /home/test/Desktop/
remote system password:
DOCKER JENKINS
build normal docker image and build that in the terminal
docker build -t new_flask .
now in another terminal run the jenkin command for the ubuntu (take from above)
now in jenkin http://localhost:8080/
login ---> new item -----> freestyle project ------> add build step -----> execute shell ----> in the cmd prompt give cmd :
docker run -d --name app1 -p 5000:5000 new_flask
save
build now
http://ipaddress:5000/
TESTING IN JENKINS
have two file in a folder
hello.py
# hello.py
def say_hello():
return "Hello, World!"
if __name__ == "__main__":
print(say_hello())
test_hello.py
# test_hello.py
import unittest
from hello import say_hello
class TestHelloWorld(unittest.TestCase):
def test_say_hello(self):
self.assertEqual(say_hello(), "Hello, World!")
if __name__ == "__main__":
unittest.main()
add these to a git repo
now create a jenkins freestyle prooject
git le add git repo
add build step "execute over window batch"
now add the command
" python -m unittest discover -s . -p "test_*.py" "
svae and buold now
o/p ----? OK
ERAI FILE TRANSFER IN JENKINS
step 1 : ssh establishment
till ssh copyid
for jenkins
in a terminal give java -jar jenkins.war --logfile=/home/USER/jenkins.log
now create a freestyle project in jenkins
add build step le " execute shell "
the give scp command in the cmd box
scp hello.sh remoteusername@remoteipaddress:/home/codebind (Where to save in the remote system)
ANNU QUESTION
nano script.sh
in script.sh add the command
scp annu.txt pakathuveetuusername@pakathuvetuipaddress: nandhana.txt ---- annu sending to nandhana
bash script.sh