Skip to content

Instantly share code, notes, and snippets.

@mmehta-10
Last active June 16, 2021 17:50
Show Gist options
  • Save mmehta-10/1b97c882203766a16a0910780af7ca86 to your computer and use it in GitHub Desktop.
Save mmehta-10/1b97c882203766a16a0910780af7ca86 to your computer and use it in GitHub Desktop.
network-policy-allow-traffic-on-port-8080-from-another-ns
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: NP1
namespace: NS1
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: ns2
ports:
- port: 8080
egress:
- to:
- namespaceSelector: {}
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- port: 53
protocol: UDP

Install packages

yum install -y certbot python2-certbot-apache mod_ssl

Create wildcard certs for domain *.meghamehta.tech

certbot certonly --manual \
  --preferred-challenges=dns \
  --email <email> \
  --server https://acme-v02.api.letsencrypt.org/directory \
  --agree-tos \
  --manual-public-ip-logging-ok \
  -d "*.meghamehta.tech"

Following text appears in the console -


Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for *.meghamehta.tech

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name:

_acme-challenge.meghamehta.tech.

with the following value:

<long-alphanumeric-string>

Before continuing, verify the TXT record has been deployed. Depending on the DNS
provider, this may take some time, from a few seconds to multiple minutes. You can
check if it has finished deploying with aid of online tools, such as the Google
Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/_acme-challenge.domain-megha.com.
Look for one or more bolded line(s) below the line ';ANSWER'. It should show the
value(s) you've just added.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

Copy the <long-alphanumeric-string> to the TXT DNS record for this domain and apply changes. Press Enter after that. If verification is successful, the following msg should appear -


Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/meghamehta.tech/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/meghamehta.tech/privkey.pem
This certificate expires on 2021-09-14.
These files will be updated when the certificate renews.

For using wildcard certificates, the file /etc/letsencrypt/live/meghamehta.tech/fullchain.pem is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment