Skip to content

Commit d47d988

Browse files
committed
update harbor docs
1 parent 0d4d623 commit d47d988

File tree

10 files changed

+543
-20
lines changed

10 files changed

+543
-20
lines changed

module10/harbor/harbor.MD

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ kubectl create ns harbor
66
```
77
### update values.yaml
88
```
9-
vi .harbor/values.yaml and change
9+
vi ./harbor/values.yaml and change
1010
1111
1212
expose:
@@ -25,28 +25,26 @@ helm install harbor ./harbor -n harbor
2525
192.168.34.2:30002
2626
admin/Harbor12345
2727
```
28-
### add insecure registry to docker client and restart docker
29-
```
30-
{
31-
"features": {
32-
"buildkit": true
33-
},
34-
"experimental": false,
35-
"builder": {
36-
"gc": {
37-
"enabled": true,
38-
"defaultKeepStorage": "20GB"
39-
}
40-
},
41-
"insecure-registries": [
42-
"core.harbor.domain:32177"
43-
]
44-
}
28+
### download repository certs from
29+
```
30+
https://192.168.34.2:30003/harbor/projects/1/repositories
31+
```
32+
### copy the downloaded ca.crt to vm docker certs configuration folder
33+
```
34+
mkdir /etc/docker/certs.d/core.harbor.domain
35+
copy the ca.crt to this folder
36+
systemctl restart docker
37+
```
38+
### edit /etc/hosts to map core.harbor.domain to harbor svc clusterip
39+
```
40+
10.104.231.99 core.harbor.domain
4541
```
4642
### docker login
4743
```
48-
docker login -u harbor_registry_user -p harbor_registry_password core.harbor.domain:32083
44+
docker login -u admin -p Harbor12345 core.harbor.domain
4945
```
46+
### docker tag a image to core.harbor.domain and push it and you will see it in harbor portal
47+
5048
### check repositories and blobs
5149
```
5250
kubectl exec -it harbor-registry-7d686859d7-xs5nv -n harbor bash
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1+
### enable sidecar auto inject
2+
```
3+
kubectl label namespace default istio-injection=enabled
4+
```
5+
### cd istio root
6+
```
7+
cd istio-1.12.0/
8+
```
9+
### create bookinfo app
10+
```
11+
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
12+
kubectl get pods
13+
```
14+
### create expose to gateway
15+
```
16+
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
17+
```
18+
### check ingress service http nodePort
19+
```
20+
kubectl get svc -n istio-system
21+
```
22+
### access productpage
23+
```
24+
curl http://192.168.34.2:31783/productpage
25+
```
26+
27+
### secure the gateway by https protocol
128
```
229
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -subj '/O=cncamp Inc./CN=192.168.34.2' -keyout bookinfo.key -out bookinfo.crt
330
kubectl create -n istio-system secret tls bookinfo-credential --key=bookinfo.key --cert=bookinfo.crt
431
kubectl apply -f https-gateway.yaml
5-
```
32+
```
33+
### access product page via safari(chrome blocks self sign certs)
34+
```
35+
https://192.168.34.2:31106/productpage
36+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: security.istio.io/v1beta1
2+
kind: AuthorizationPolicy
3+
metadata:
4+
name: require-jwt
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: details
9+
action: ALLOW
10+
rules:
11+
- from:
12+
- source:
13+
requestPrincipals: ["testing@secure.istio.io/testing@secure.istio.io"]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
### create RequestAuthentication which enables jwt token validation
2+
after this, requests with invalid token will be rejected
3+
requests without token or with valid token will be accepted
4+
```
5+
kubectl apply -f requestauthentication.yaml
6+
```
7+
### create AuthorizationPolicy which enables check of authorization
8+
after this, requests without token will be rejected
9+
```
10+
kubectl apply -f authorizationpolicy.yaml
11+
```
12+
### access productpage and you will see
13+
```
14+
Sorry, product details are currently unavailable for this book.
15+
```
16+
### get jwt token
17+
```
18+
TOKEN_GROUP=$(curl https://raw.githubusercontent.com/istio/istio/release-1.12/security/tools/jwt/samples/groups-scope.jwt -s) && echo "$TOKEN_GROUP" | cut -d '.' -f2 - | base64 --decode -
19+
20+
echo eyJhbGciOiJSUzI1NiIsImtpZCI6IkRIRmJwb0lVcXJZOHQyenBBMnFYZkNtcjVWTzVaRXI0UnpIVV8tZW52dlEiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjM1MzczOTExMDQsImdyb3VwcyI6WyJncm91cDEiLCJncm91cDIiXSwiaWF0IjoxNTM3MzkxMTA0LCJpc3MiOiJ0ZXN0aW5nQHNlY3VyZS5pc3Rpby5pbyIsInNjb3BlIjpbInNjb3BlMSIsInNjb3BlMiJdLCJzdWIiOiJ0ZXN0aW5nQHNlY3VyZS5pc3Rpby5pbyJ9.EdJnEZSH6X8hcyEii7c8H5lnhgjB5dwo07M5oheC8Xz8mOllyg--AHCFWHybM48reunF--oGaG6IXVngCEpVF0_P5DwsUoBgpPmK1JOaKN6_pe9sh0ZwTtdgK_RP01PuI7kUdbOTlkuUi2AO-qUyOm7Art2POzo36DLQlUXv8Ad7NBOqfQaKjE9ndaPWT7aexUsBHxmgiGbz1SyLH879f7uHYPbPKlpHU6P9S-DaKnGLaEchnoKnov7ajhrEhGXAQRukhDPKUHO9L30oPIr5IJllEQfHYtt6IZvlNUGeLUcif3wpry1R5tBXRicx2sXMQ7LyuDremDbcNy_iE76Upg| cut -d '.' -f2 -|base64 -d
21+
{"exp":3537391104,"groups":["group1","group2"],"iat":1537391104,"iss":"testing@secure.istio.io","scope":["scope1","scope2"],"sub":"testing@secure.istio.io"}
22+
```
23+
24+
### add jwt token to productpage source code
25+
```
26+
cat productpage-v2/productpage.py
27+
```
28+
### build docker images for productpage v2 with jwt token
29+
### create product page v2
30+
```
31+
kubectl apply -f productpage-v2/productpage.py
32+
```
33+
### access productpage and you will see error in 50% percents
34+
```
35+
Sorry, product details are currently unavailable for this book.
36+
```
37+
### this is how microservice talks to each others with jwt token

module15/2.security-hardening/jwt/jwt.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ TOKEN_GROUP=$(curl https://raw.githubusercontent.com/istio/istio/release-1.12/se
3131
echo eyJhbGciOiJSUzI1NiIsImtpZCI6IkRIRmJwb0lVcXJZOHQyenBBMnFYZkNtcjVWTzVaRXI0UnpIVV8tZW52dlEiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjM1MzczOTExMDQsImdyb3VwcyI6WyJncm91cDEiLCJncm91cDIiXSwiaWF0IjoxNTM3MzkxMTA0LCJpc3MiOiJ0ZXN0aW5nQHNlY3VyZS5pc3Rpby5pbyIsInNjb3BlIjpbInNjb3BlMSIsInNjb3BlMiJdLCJzdWIiOiJ0ZXN0aW5nQHNlY3VyZS5pc3Rpby5pbyJ9.EdJnEZSH6X8hcyEii7c8H5lnhgjB5dwo07M5oheC8Xz8mOllyg--AHCFWHybM48reunF--oGaG6IXVngCEpVF0_P5DwsUoBgpPmK1JOaKN6_pe9sh0ZwTtdgK_RP01PuI7kUdbOTlkuUi2AO-qUyOm7Art2POzo36DLQlUXv8Ad7NBOqfQaKjE9ndaPWT7aexUsBHxmgiGbz1SyLH879f7uHYPbPKlpHU6P9S-DaKnGLaEchnoKnov7ajhrEhGXAQRukhDPKUHO9L30oPIr5IJllEQfHYtt6IZvlNUGeLUcif3wpry1R5tBXRicx2sXMQ7LyuDremDbcNy_iE76Upg| cut -d '.' -f2 -|base64 -d
3232
{"exp":3537391104,"groups":["group1","group2"],"iat":1537391104,"iss":"testing@secure.istio.io","scope":["scope1","scope2"],"sub":"testing@secure.istio.io"}
3333
```
34+
### access gateway with jwt to
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM docker.io/istio/examples-bookinfo-productpage-v1:1.16.2
2+
ADD productpage.py /opt/microservices

0 commit comments

Comments
 (0)