def generate_rfc1123(length=10):
    'Generate a random string compliant with RFC 1123.\n\n    https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names\n\n    param: length - the length of the string to generate\n    '
    length = (253 if (length > 253) else length)
    first_last_opts = (string.ascii_lowercase + string.digits)
    middle_opts = ((first_last_opts + '-') + '.')
    length -= 2
    rand_str = ((random.SystemRandom().choice(first_last_opts) + ''.join((random.SystemRandom().choice(middle_opts) for _ in range(length)))) + random.SystemRandom().choice(first_last_opts))
    return rand_str
Generate a random string compliant with RFC 1123.

https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names

param: length - the length of the string to generate
def generate_rfc1123(length=10):
    'Generate a random string compliant with RFC 1123.\n\n    https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names\n\n    param: length - the length of the string to generate\n    '
    length = (253 if (length > 253) else length)
    first_last_opts = (string.ascii_lowercase + string.digits)
    middle_opts = ((first_last_opts + '-') + '.')
    length -= 2
    rand_str = ((random.SystemRandom().choice(first_last_opts) + .join((random.SystemRandom().choice(middle_opts) for _ in range(length)))) + random.SystemRandom().choice(first_last_opts))
    return rand_str