Beispiel #1
0
 def update_ingress(self, pykube_ingress, cert_pem, key_pem):
     new_secret = {}
     k8s.set_data(new_secret, SECRET_DATA_CERT_PEM, cert_pem)
     k8s.set_data(new_secret, SECRET_DATA_KEY_PEM, key_pem)
     old_secret = k8s.unwrap(self.kubernetes.fetch_pykube_secret_from_pykube_ingress(pykube_ingress))
     if k8s.compare_data(new_secret, old_secret, SECRET_DATA_CERT_PEM) and k8s.compare_data(new_secret, old_secret, SECRET_DATA_KEY_PEM):
         log.info("Found existing secret {}. TLS Data matches. No update required.".format(k8s.get_name(old_secret)))
     else:
         secret_name = self._set_secret_name_and_tag(new_secret)
         self.kubernetes.create_secret(new_secret)
         k8s.set_tls_secret_name(k8s.unwrap(pykube_ingress), secret_name)
         pykube_ingress.update()
         log.info("Updated ingress object {} with secret {}".format(pykube_ingress.name, secret_name))
Beispiel #2
0
 def test_compare_data_false(self):
     a = {'foo': 'bar'}
     b = {'foo': 'not bar'}
     k8s.set_data(a, 'key', 'binary')
     k8s.set_data(b, 'key', 'OTHER')
     self.assertFalse(k8s.compare_data(a, b, 'key'))
Beispiel #3
0
 def test_compare_data(self):
     a = {'foo': 'bar'}
     b = {'foo': 'not bar'}
     k8s.set_data(a, 'key', 'binary')
     k8s.set_data(b, 'key', 'binary')
     self.assertTrue(k8s.compare_data(a, b, 'key'))
 def test_compare_data(self):
     a = {'foo': 'bar'}
     b = {'foo': 'not bar'}
     k8s.set_data(a, 'key', 'binary')
     k8s.set_data(b, 'key', 'binary')
     self.assertTrue(k8s.compare_data(a, b, 'key'))